diff --git a/.flake8 b/.flake8 index 29227d4..2e43874 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 44c78f7..757c9dc 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 0000000..311ebbb --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 0000000..41bff0b --- /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 466597e..6def37a 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,8 @@ 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: v0 + handleGHRelease: true + releaseType: python diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb..238b87b 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 62eb5a7..46d2371 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 d1143f5..70eefb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,25 @@ # Changelog -### [1.2.2](https://github.com/googleapis/python-binary-authorization/compare/v1.2.1...v1.2.2) (2022-03-05) +## [1.2.3](https://github.com/googleapis/python-binary-authorization/compare/v1.2.2...v1.2.3) (2022-06-03) + + +### Bug Fixes + +* **deps:** require protobuf <4.0.0dev ([#148](https://github.com/googleapis/python-binary-authorization/issues/148)) ([2768020](https://github.com/googleapis/python-binary-authorization/commit/276802072057a817993311b92111ee4f84c7505a)) + + +### Documentation + +* fix changelog header to consistent size ([#149](https://github.com/googleapis/python-binary-authorization/issues/149)) ([3d3d7e4](https://github.com/googleapis/python-binary-authorization/commit/3d3d7e40793834a4d079e83d21db6ec1fe285718)) + +## [1.2.2](https://github.com/googleapis/python-binary-authorization/compare/v1.2.1...v1.2.2) (2022-03-05) ### Bug Fixes * **deps:** require google-api-core>=1.31.5, >=2.3.2 ([#126](https://github.com/googleapis/python-binary-authorization/issues/126)) ([2b7e982](https://github.com/googleapis/python-binary-authorization/commit/2b7e982e09b85570af842acba3ca6c48831a49e2)) -### [1.2.1](https://github.com/googleapis/python-binary-authorization/compare/v1.2.0...v1.2.1) (2022-02-11) +## [1.2.1](https://github.com/googleapis/python-binary-authorization/compare/v1.2.0...v1.2.1) (2022-02-11) ### Bug Fixes @@ -30,7 +42,7 @@ * **v1beta1:** add SystemPolicyV1Beta1 service ([f25d17a](https://www.github.com/googleapis/python-binary-authorization/commit/f25d17abaefe4a2d317161ec15b867b33eb3e8ba)) * **v1beta1:** update SignatureAlgorithm enum to match algorithm names in KMS ([f25d17a](https://www.github.com/googleapis/python-binary-authorization/commit/f25d17abaefe4a2d317161ec15b867b33eb3e8ba)) -### [1.0.1](https://www.github.com/googleapis/python-binary-authorization/compare/v1.0.0...v1.0.1) (2021-11-01) +## [1.0.1](https://www.github.com/googleapis/python-binary-authorization/compare/v1.0.0...v1.0.1) (2021-11-01) ### Bug Fixes @@ -64,7 +76,7 @@ * add context manager support in client ([#84](https://www.github.com/googleapis/python-binary-authorization/issues/84)) ([0991f56](https://www.github.com/googleapis/python-binary-authorization/commit/0991f564af01dc8b0172693290a9aba566035848)) -### [0.4.1](https://www.github.com/googleapis/python-binary-authorization/compare/v0.4.0...v0.4.1) (2021-09-30) +## [0.4.1](https://www.github.com/googleapis/python-binary-authorization/compare/v0.4.0...v0.4.1) (2021-09-30) ### Bug Fixes @@ -90,7 +102,7 @@ * fix broken links in README ([cd828ec](https://www.github.com/googleapis/python-binary-authorization/commit/cd828ec45edb5a297607ea7e9f94c39e68ef2d7d)) -### [0.3.1](https://www.github.com/googleapis/python-binary-authorization/compare/v0.3.0...v0.3.1) (2021-07-26) +## [0.3.1](https://www.github.com/googleapis/python-binary-authorization/compare/v0.3.0...v0.3.1) (2021-07-26) ### Bug Fixes @@ -125,14 +137,14 @@ * omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-binary-authorization/issues/1127)) ([#43](https://www.github.com/googleapis/python-binary-authorization/issues/43)) ([726d589](https://www.github.com/googleapis/python-binary-authorization/commit/726d58920de4e97a70cbbe1fd88ac427224ba1ea)), closes [#1126](https://www.github.com/googleapis/python-binary-authorization/issues/1126) -### [0.2.2](https://www.github.com/googleapis/python-binary-authorization/compare/v0.2.1...v0.2.2) (2021-06-16) +## [0.2.2](https://www.github.com/googleapis/python-binary-authorization/compare/v0.2.1...v0.2.2) (2021-06-16) ### Bug Fixes * exclude docs and tests from package ([#39](https://www.github.com/googleapis/python-binary-authorization/issues/39)) ([a90d7f4](https://www.github.com/googleapis/python-binary-authorization/commit/a90d7f46ca54c3bf805208bff157cfbc48a14234)) -### [0.2.1](https://www.github.com/googleapis/python-binary-authorization/compare/v0.2.0...v0.2.1) (2021-05-25) +## [0.2.1](https://www.github.com/googleapis/python-binary-authorization/compare/v0.2.0...v0.2.1) (2021-05-25) ### Bug Fixes @@ -146,7 +158,7 @@ * Publish Binary Authorization ContinuousValidationEvent proto ([#31](https://www.github.com/googleapis/python-binary-authorization/issues/31)) ([d3d2abe](https://www.github.com/googleapis/python-binary-authorization/commit/d3d2abeb22bad714de0591916c1065fda7305a92)) -### [0.1.1](https://www.github.com/googleapis/python-binary-authorization/compare/v0.1.0...v0.1.1) (2021-04-01) +## [0.1.1](https://www.github.com/googleapis/python-binary-authorization/compare/v0.1.0...v0.1.1) (2021-04-01) ### Bug Fixes diff --git a/docs/conf.py b/docs/conf.py index 3e51f11..3551c21 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -361,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/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py index 87a44fb..a7e52ae 100644 --- a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py +++ b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/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 @@ -247,14 +247,13 @@ async def get_policy( [policy][google.cloud.binaryauthorization.v1.Policy] if the project does not have one. - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_get_policy(): + async def sample_get_policy(): # Create a client - client = binaryauthorization_v1.BinauthzManagementServiceV1Client() + client = binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1.GetPolicyRequest( @@ -262,7 +261,7 @@ def sample_get_policy(): ) # Make the request - response = client.get_policy(request=request) + response = await client.get_policy(request=request) # Handle the response print(response) @@ -333,7 +332,12 @@ def sample_get_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -356,14 +360,13 @@ async def update_policy( NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed. - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_update_policy(): + async def sample_update_policy(): # Create a client - client = binaryauthorization_v1.BinauthzManagementServiceV1Client() + client = binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient() # Initialize request argument(s) policy = binaryauthorization_v1.Policy() @@ -375,7 +378,7 @@ def sample_update_policy(): ) # Make the request - response = client.update_policy(request=request) + response = await client.update_policy(request=request) # Handle the response print(response) @@ -451,7 +454,12 @@ def sample_update_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -476,14 +484,13 @@ async def create_attestor( the [attestor][google.cloud.binaryauthorization.v1.Attestor] already exists. - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_create_attestor(): + async def sample_create_attestor(): # Create a client - client = binaryauthorization_v1.BinauthzManagementServiceV1Client() + client = binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient() # Initialize request argument(s) attestor = binaryauthorization_v1.Attestor() @@ -497,7 +504,7 @@ def sample_create_attestor(): ) # Make the request - response = client.create_attestor(request=request) + response = await client.create_attestor(request=request) # Handle the response print(response) @@ -581,7 +588,12 @@ def sample_create_attestor(): ) # 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 @@ -601,14 +613,13 @@ async def get_attestor( [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_get_attestor(): + async def sample_get_attestor(): # Create a client - client = binaryauthorization_v1.BinauthzManagementServiceV1Client() + client = binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1.GetAttestorRequest( @@ -616,7 +627,7 @@ def sample_get_attestor(): ) # Make the request - response = client.get_attestor(request=request) + response = await client.get_attestor(request=request) # Handle the response print(response) @@ -688,7 +699,12 @@ def sample_get_attestor(): ) # 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 @@ -708,14 +724,13 @@ async def update_attestor( [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_update_attestor(): + async def sample_update_attestor(): # Create a client - client = binaryauthorization_v1.BinauthzManagementServiceV1Client() + client = binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient() # Initialize request argument(s) attestor = binaryauthorization_v1.Attestor() @@ -727,7 +742,7 @@ def sample_update_attestor(): ) # Make the request - response = client.update_attestor(request=request) + response = await client.update_attestor(request=request) # Handle the response print(response) @@ -804,7 +819,12 @@ def sample_update_attestor(): ) # 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 @@ -821,14 +841,13 @@ async def list_attestors( r"""Lists [attestors][google.cloud.binaryauthorization.v1.Attestor]. Returns INVALID_ARGUMENT if the project does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_list_attestors(): + async def sample_list_attestors(): # Create a client - client = binaryauthorization_v1.BinauthzManagementServiceV1Client() + client = binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1.ListAttestorsRequest( @@ -839,7 +858,7 @@ def sample_list_attestors(): page_result = client.list_attestors(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -912,12 +931,20 @@ def sample_list_attestors(): ) # 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.ListAttestorsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -938,14 +965,13 @@ async def delete_attestor( [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_delete_attestor(): + async def sample_delete_attestor(): # Create a client - client = binaryauthorization_v1.BinauthzManagementServiceV1Client() + client = binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1.DeleteAttestorRequest( @@ -953,7 +979,7 @@ def sample_delete_attestor(): ) # Make the request - client.delete_attestor(request=request) + await client.delete_attestor(request=request) Args: request (Union[google.cloud.binaryauthorization_v1.types.DeleteAttestorRequest, dict]): @@ -1016,7 +1042,10 @@ def sample_delete_attestor(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def __aenter__(self): diff --git a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py index bf06a79..7d14224 100644 --- a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py +++ b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/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 @@ -62,7 +62,8 @@ class BinauthzManagementServiceV1ClientMeta(type): ] = BinauthzManagementServiceV1GrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[BinauthzManagementServiceV1Transport]: """Returns an appropriate transport class. @@ -177,10 +178,14 @@ def transport(self) -> BinauthzManagementServiceV1Transport: return self._transport @staticmethod - def attestor_path(project: str, attestor: str,) -> str: + def attestor_path( + project: str, + attestor: str, + ) -> str: """Returns a fully-qualified attestor string.""" return "projects/{project}/attestors/{attestor}".format( - project=project, attestor=attestor, + project=project, + attestor=attestor, ) @staticmethod @@ -190,9 +195,13 @@ def parse_attestor_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def policy_path(project: str,) -> str: + def policy_path( + project: str, + ) -> str: """Returns a fully-qualified policy string.""" - return "projects/{project}/policy".format(project=project,) + return "projects/{project}/policy".format( + project=project, + ) @staticmethod def parse_policy_path(path: str) -> Dict[str, str]: @@ -201,7 +210,9 @@ def parse_policy_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, @@ -214,9 +225,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]: @@ -225,9 +240,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]: @@ -236,9 +255,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]: @@ -247,10 +270,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 @@ -445,7 +472,6 @@ def get_policy( [policy][google.cloud.binaryauthorization.v1.Policy] if the project does not have one. - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -521,7 +547,12 @@ def sample_get_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -544,7 +575,6 @@ def update_policy( NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed. - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -629,7 +659,12 @@ def sample_update_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -654,7 +689,6 @@ def create_attestor( the [attestor][google.cloud.binaryauthorization.v1.Attestor] already exists. - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -759,7 +793,12 @@ def sample_create_attestor(): ) # 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 @@ -779,7 +818,6 @@ def get_attestor( [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -856,7 +894,12 @@ def sample_get_attestor(): ) # 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 @@ -876,7 +919,6 @@ def update_attestor( [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -962,7 +1004,12 @@ def sample_update_attestor(): ) # 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 @@ -979,7 +1026,6 @@ def list_attestors( r"""Lists [attestors][google.cloud.binaryauthorization.v1.Attestor]. Returns INVALID_ARGUMENT if the project does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -1060,12 +1106,20 @@ def sample_list_attestors(): ) # 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.ListAttestorsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1086,7 +1140,6 @@ def delete_attestor( [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -1154,7 +1207,10 @@ def sample_delete_attestor(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def __enter__(self): diff --git a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py index 8ca9c25..aa75521 100644 --- a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py +++ b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py @@ -82,6 +82,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" @@ -153,7 +154,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_attestor: gapic_v1.method.wrap_method( - self.create_attestor, default_timeout=600.0, client_info=client_info, + self.create_attestor, + default_timeout=600.0, + client_info=client_info, ), self.get_attestor: gapic_v1.method.wrap_method( self.get_attestor, @@ -220,9 +223,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() @@ -288,5 +291,9 @@ def delete_attestor( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("BinauthzManagementServiceV1Transport",) diff --git a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc.py b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc.py index aaa204c..1b9ed59 100644 --- a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc.py +++ b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc.py @@ -232,8 +232,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 @@ -456,5 +455,9 @@ def delete_attestor( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("BinauthzManagementServiceV1GrpcTransport",) diff --git a/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py b/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py index 13997b9..6ae10ec 100644 --- a/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py +++ b/google/cloud/binaryauthorization_v1/services/system_policy_v1/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 @@ -215,14 +215,13 @@ async def get_system_policy( r"""Gets the current system policy in the specified location. - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_get_system_policy(): + async def sample_get_system_policy(): # Create a client - client = binaryauthorization_v1.SystemPolicyV1Client() + client = binaryauthorization_v1.SystemPolicyV1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1.GetSystemPolicyRequest( @@ -230,7 +229,7 @@ def sample_get_system_policy(): ) # Make the request - response = client.get_system_policy(request=request) + response = await client.get_system_policy(request=request) # Handle the response print(response) @@ -291,7 +290,12 @@ def sample_get_system_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py b/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py index e8f4d10..abe2571 100644 --- a/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py +++ b/google/cloud/binaryauthorization_v1/services/system_policy_v1/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 @@ -56,7 +56,10 @@ class SystemPolicyV1ClientMeta(type): _transport_registry["grpc"] = SystemPolicyV1GrpcTransport _transport_registry["grpc_asyncio"] = SystemPolicyV1GrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[SystemPolicyV1Transport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[SystemPolicyV1Transport]: """Returns an appropriate transport class. Args: @@ -161,9 +164,13 @@ def transport(self) -> SystemPolicyV1Transport: return self._transport @staticmethod - def policy_path(project: str,) -> str: + def policy_path( + project: str, + ) -> str: """Returns a fully-qualified policy string.""" - return "projects/{project}/policy".format(project=project,) + return "projects/{project}/policy".format( + project=project, + ) @staticmethod def parse_policy_path(path: str) -> Dict[str, str]: @@ -172,7 +179,9 @@ def parse_policy_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, @@ -185,9 +194,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]: @@ -196,9 +209,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]: @@ -207,9 +224,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]: @@ -218,10 +239,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 @@ -407,7 +432,6 @@ def get_system_policy( r"""Gets the current system policy in the specified location. - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -483,7 +507,12 @@ def sample_get_system_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py b/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py index cdaedf4..4b3b570 100644 --- a/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py +++ b/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py @@ -81,6 +81,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,16 +123,18 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.get_system_policy: gapic_v1.method.wrap_method( - self.get_system_policy, default_timeout=None, client_info=client_info, + self.get_system_policy, + default_timeout=None, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -144,5 +147,9 @@ def get_system_policy( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("SystemPolicyV1Transport",) diff --git a/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc.py b/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc.py index 7706211..95f18fc 100644 --- a/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc.py +++ b/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc.py @@ -225,8 +225,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 @@ -259,5 +258,9 @@ def get_system_policy( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("SystemPolicyV1GrpcTransport",) diff --git a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py index 9858b14..1238f8b 100644 --- a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py +++ b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/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 @@ -211,14 +211,13 @@ async def validate_attestation_occurrence( r"""Returns whether the given Attestation for the given image URI was signed by the given Attestor - .. code-block:: python from google.cloud import binaryauthorization_v1 - def sample_validate_attestation_occurrence(): + async def sample_validate_attestation_occurrence(): # Create a client - client = binaryauthorization_v1.ValidationHelperV1Client() + client = binaryauthorization_v1.ValidationHelperV1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1.ValidateAttestationOccurrenceRequest( @@ -228,7 +227,7 @@ def sample_validate_attestation_occurrence(): ) # Make the request - response = client.validate_attestation_occurrence(request=request) + response = await client.validate_attestation_occurrence(request=request) # Handle the response print(response) @@ -267,7 +266,12 @@ def sample_validate_attestation_occurrence(): ) # 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 diff --git a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py index 554605d..03b0f24 100644 --- a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py +++ b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/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 @@ -55,7 +55,8 @@ class ValidationHelperV1ClientMeta(type): _transport_registry["grpc_asyncio"] = ValidationHelperV1GrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[ValidationHelperV1Transport]: """Returns an appropriate transport class. @@ -161,7 +162,9 @@ def transport(self) -> ValidationHelperV1Transport: return self._transport @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, @@ -174,9 +177,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]: @@ -185,9 +192,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]: @@ -196,9 +207,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]: @@ -207,10 +222,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 @@ -395,7 +414,6 @@ def validate_attestation_occurrence( r"""Returns whether the given Attestation for the given image URI was signed by the given Attestor - .. code-block:: python from google.cloud import binaryauthorization_v1 @@ -454,7 +472,12 @@ def sample_validate_attestation_occurrence(): ) # 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 diff --git a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py index 5268466..54e3d84 100644 --- a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py +++ b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py @@ -80,6 +80,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" @@ -130,9 +131,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() @@ -148,5 +149,9 @@ def validate_attestation_occurrence( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("ValidationHelperV1Transport",) diff --git a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc.py b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc.py index ef1c5f6..5559008 100644 --- a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc.py +++ b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc.py @@ -224,8 +224,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 @@ -264,5 +263,9 @@ def validate_attestation_occurrence( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("ValidationHelperV1GrpcTransport",) diff --git a/google/cloud/binaryauthorization_v1/types/resources.py b/google/cloud/binaryauthorization_v1/types/resources.py index 7838f10..9bbfb50 100644 --- a/google/cloud/binaryauthorization_v1/types/resources.py +++ b/google/cloud/binaryauthorization_v1/types/resources.py @@ -57,21 +57,21 @@ class Policy(proto.Message): permitted. This feature is typically used to exclude Google or third-party infrastructure images from Binary Authorization policies. - cluster_admission_rules (Sequence[google.cloud.binaryauthorization_v1.types.Policy.ClusterAdmissionRulesEntry]): + cluster_admission_rules (Mapping[str, google.cloud.binaryauthorization_v1.types.AdmissionRule]): Optional. Per-cluster admission rules. Cluster spec format: ``location.clusterId``. There can be at most one admission rule per cluster spec. A ``location`` is either a compute zone (e.g. us-central1-a) or a region (e.g. us-central1). For ``clusterId`` syntax restrictions see https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters. - kubernetes_namespace_admission_rules (Sequence[google.cloud.binaryauthorization_v1.types.Policy.KubernetesNamespaceAdmissionRulesEntry]): + kubernetes_namespace_admission_rules (Mapping[str, google.cloud.binaryauthorization_v1.types.AdmissionRule]): Optional. Per-kubernetes-namespace admission rules. K8s namespace spec format: [a-z.-]+, e.g. 'some-namespace' - kubernetes_service_account_admission_rules (Sequence[google.cloud.binaryauthorization_v1.types.Policy.KubernetesServiceAccountAdmissionRulesEntry]): + kubernetes_service_account_admission_rules (Mapping[str, google.cloud.binaryauthorization_v1.types.AdmissionRule]): Optional. Per-kubernetes-service-account admission rules. Service account spec format: ``namespace:serviceaccount``. e.g. 'test-ns:default' - istio_service_identity_admission_rules (Sequence[google.cloud.binaryauthorization_v1.types.Policy.IstioServiceIdentityAdmissionRulesEntry]): + istio_service_identity_admission_rules (Mapping[str, google.cloud.binaryauthorization_v1.types.AdmissionRule]): Optional. Per-istio-service-identity admission rules. Istio service identity spec format: @@ -94,30 +94,58 @@ class GlobalPolicyEvaluationMode(proto.Enum): ENABLE = 1 DISABLE = 2 - name = proto.Field(proto.STRING, number=1,) - description = proto.Field(proto.STRING, number=6,) + name = proto.Field( + proto.STRING, + number=1, + ) + description = proto.Field( + proto.STRING, + number=6, + ) global_policy_evaluation_mode = proto.Field( - proto.ENUM, number=7, enum=GlobalPolicyEvaluationMode, + proto.ENUM, + number=7, + enum=GlobalPolicyEvaluationMode, ) admission_whitelist_patterns = proto.RepeatedField( - proto.MESSAGE, number=2, message="AdmissionWhitelistPattern", + proto.MESSAGE, + number=2, + message="AdmissionWhitelistPattern", ) cluster_admission_rules = proto.MapField( - proto.STRING, proto.MESSAGE, number=3, message="AdmissionRule", + proto.STRING, + proto.MESSAGE, + number=3, + message="AdmissionRule", ) kubernetes_namespace_admission_rules = proto.MapField( - proto.STRING, proto.MESSAGE, number=10, message="AdmissionRule", + proto.STRING, + proto.MESSAGE, + number=10, + message="AdmissionRule", ) kubernetes_service_account_admission_rules = proto.MapField( - proto.STRING, proto.MESSAGE, number=8, message="AdmissionRule", + proto.STRING, + proto.MESSAGE, + number=8, + message="AdmissionRule", ) istio_service_identity_admission_rules = proto.MapField( - proto.STRING, proto.MESSAGE, number=9, message="AdmissionRule", + proto.STRING, + proto.MESSAGE, + number=9, + message="AdmissionRule", ) default_admission_rule = proto.Field( - proto.MESSAGE, number=4, message="AdmissionRule", + proto.MESSAGE, + number=4, + message="AdmissionRule", + ) + update_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, ) - update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) class AdmissionWhitelistPattern(proto.Message): @@ -135,7 +163,10 @@ class AdmissionWhitelistPattern(proto.Message): wildcard which matches subdirectories of a given entry. """ - name_pattern = proto.Field(proto.STRING, number=1,) + name_pattern = proto.Field( + proto.STRING, + number=1, + ) class AdmissionRule(proto.Message): @@ -187,9 +218,20 @@ class EnforcementMode(proto.Enum): ENFORCED_BLOCK_AND_AUDIT_LOG = 1 DRYRUN_AUDIT_LOG_ONLY = 2 - evaluation_mode = proto.Field(proto.ENUM, number=1, enum=EvaluationMode,) - require_attestations_by = proto.RepeatedField(proto.STRING, number=2,) - enforcement_mode = proto.Field(proto.ENUM, number=3, enum=EnforcementMode,) + evaluation_mode = proto.Field( + proto.ENUM, + number=1, + enum=EvaluationMode, + ) + require_attestations_by = proto.RepeatedField( + proto.STRING, + number=2, + ) + enforcement_mode = proto.Field( + proto.ENUM, + number=3, + enum=EnforcementMode, + ) class Attestor(proto.Message): @@ -219,12 +261,25 @@ class Attestor(proto.Message): updated. """ - name = proto.Field(proto.STRING, number=1,) - description = proto.Field(proto.STRING, number=6,) + name = proto.Field( + proto.STRING, + number=1, + ) + description = proto.Field( + proto.STRING, + number=6, + ) user_owned_grafeas_note = proto.Field( - proto.MESSAGE, number=3, oneof="attestor_type", message="UserOwnedGrafeasNote", + proto.MESSAGE, + number=3, + oneof="attestor_type", + message="UserOwnedGrafeasNote", + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, ) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) class UserOwnedGrafeasNote(proto.Message): @@ -268,11 +323,19 @@ class UserOwnedGrafeasNote(proto.Message): email based on a different naming pattern. """ - note_reference = proto.Field(proto.STRING, number=1,) + note_reference = proto.Field( + proto.STRING, + number=1, + ) public_keys = proto.RepeatedField( - proto.MESSAGE, number=2, message="AttestorPublicKey", + proto.MESSAGE, + number=2, + message="AttestorPublicKey", + ) + delegation_service_account_email = proto.Field( + proto.STRING, + number=3, ) - delegation_service_account_email = proto.Field(proto.STRING, number=3,) class PkixPublicKey(proto.Message): @@ -319,8 +382,15 @@ class SignatureAlgorithm(proto.Enum): ECDSA_P521_SHA512 = 11 EC_SIGN_P521_SHA512 = 11 - public_key_pem = proto.Field(proto.STRING, number=1,) - signature_algorithm = proto.Field(proto.ENUM, number=2, enum=SignatureAlgorithm,) + public_key_pem = proto.Field( + proto.STRING, + number=1, + ) + signature_algorithm = proto.Field( + proto.ENUM, + number=2, + enum=SignatureAlgorithm, + ) class AttestorPublicKey(proto.Message): @@ -370,13 +440,24 @@ class AttestorPublicKey(proto.Message): This field is a member of `oneof`_ ``public_key``. """ - comment = proto.Field(proto.STRING, number=1,) - id = proto.Field(proto.STRING, number=2,) + comment = proto.Field( + proto.STRING, + number=1, + ) + id = proto.Field( + proto.STRING, + number=2, + ) ascii_armored_pgp_public_key = proto.Field( - proto.STRING, number=3, oneof="public_key", + proto.STRING, + number=3, + oneof="public_key", ) pkix_public_key = proto.Field( - proto.MESSAGE, number=5, oneof="public_key", message="PkixPublicKey", + proto.MESSAGE, + number=5, + oneof="public_key", + message="PkixPublicKey", ) diff --git a/google/cloud/binaryauthorization_v1/types/service.py b/google/cloud/binaryauthorization_v1/types/service.py index b1a8640..eaf253c 100644 --- a/google/cloud/binaryauthorization_v1/types/service.py +++ b/google/cloud/binaryauthorization_v1/types/service.py @@ -47,7 +47,10 @@ class GetPolicyRequest(proto.Message): retrieve, in the format ``projects/*/policy``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdatePolicyRequest(proto.Message): @@ -63,7 +66,11 @@ class UpdatePolicyRequest(proto.Message): ``projects/*/policy``. """ - policy = proto.Field(proto.MESSAGE, number=1, message=resources.Policy,) + policy = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Policy, + ) class CreateAttestorRequest(proto.Message): @@ -86,9 +93,19 @@ class CreateAttestorRequest(proto.Message): ``projects/*/attestors/*``. """ - parent = proto.Field(proto.STRING, number=1,) - attestor_id = proto.Field(proto.STRING, number=2,) - attestor = proto.Field(proto.MESSAGE, number=3, message=resources.Attestor,) + parent = proto.Field( + proto.STRING, + number=1, + ) + attestor_id = proto.Field( + proto.STRING, + number=2, + ) + attestor = proto.Field( + proto.MESSAGE, + number=3, + message=resources.Attestor, + ) class GetAttestorRequest(proto.Message): @@ -101,7 +118,10 @@ class GetAttestorRequest(proto.Message): retrieve, in the format ``projects/*/attestors/*``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdateAttestorRequest(proto.Message): @@ -117,7 +137,11 @@ class UpdateAttestorRequest(proto.Message): format ``projects/*/attestors/*``. """ - attestor = proto.Field(proto.MESSAGE, number=1, message=resources.Attestor,) + attestor = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Attestor, + ) class ListAttestorsRequest(proto.Message): @@ -141,9 +165,18 @@ class ListAttestorsRequest(proto.Message): method. """ - 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 ListAttestorsResponse(proto.Message): @@ -166,9 +199,14 @@ def raw_page(self): return self attestors = proto.RepeatedField( - proto.MESSAGE, number=1, message=resources.Attestor, + proto.MESSAGE, + number=1, + message=resources.Attestor, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class DeleteAttestorRequest(proto.Message): @@ -181,7 +219,10 @@ class DeleteAttestorRequest(proto.Message): delete, in the format ``projects/*/attestors/*``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class GetSystemPolicyRequest(proto.Message): @@ -194,7 +235,10 @@ class GetSystemPolicyRequest(proto.Message): associated with a project. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ValidateAttestationOccurrenceRequest(proto.Message): @@ -223,12 +267,23 @@ class ValidateAttestationOccurrenceRequest(proto.Message): [Occurrence][grafeas.v1.Occurrence]. """ - attestor = proto.Field(proto.STRING, number=1,) + attestor = proto.Field( + proto.STRING, + number=1, + ) attestation = proto.Field( - proto.MESSAGE, number=2, message=attestation.AttestationOccurrence, + proto.MESSAGE, + number=2, + message=attestation.AttestationOccurrence, + ) + occurrence_note = proto.Field( + proto.STRING, + number=3, + ) + occurrence_resource_uri = proto.Field( + proto.STRING, + number=4, ) - occurrence_note = proto.Field(proto.STRING, number=3,) - occurrence_resource_uri = proto.Field(proto.STRING, number=4,) class ValidateAttestationOccurrenceResponse(proto.Message): @@ -249,8 +304,15 @@ class Result(proto.Enum): VERIFIED = 1 ATTESTATION_NOT_VERIFIABLE = 2 - result = proto.Field(proto.ENUM, number=1, enum=Result,) - denial_reason = proto.Field(proto.STRING, number=2,) + result = proto.Field( + proto.ENUM, + number=1, + enum=Result, + ) + denial_reason = proto.Field( + proto.STRING, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py index 51eb8e0..5d3a7c8 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py +++ b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/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 @@ -256,14 +256,13 @@ async def get_policy( [policy][google.cloud.binaryauthorization.v1beta1.Policy] if the project does not have one. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 - def sample_get_policy(): + async def sample_get_policy(): # Create a client - client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client() + client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1beta1.GetPolicyRequest( @@ -271,7 +270,7 @@ def sample_get_policy(): ) # Make the request - response = client.get_policy(request=request) + response = await client.get_policy(request=request) # Handle the response print(response) @@ -343,7 +342,12 @@ def sample_get_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -366,14 +370,13 @@ async def update_policy( Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 - def sample_update_policy(): + async def sample_update_policy(): # Create a client - client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client() + client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient() # Initialize request argument(s) policy = binaryauthorization_v1beta1.Policy() @@ -385,7 +388,7 @@ def sample_update_policy(): ) # Make the request - response = client.update_policy(request=request) + response = await client.update_policy(request=request) # Handle the response print(response) @@ -462,7 +465,12 @@ def sample_update_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -488,14 +496,13 @@ async def create_attestor( [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] already exists. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 - def sample_create_attestor(): + async def sample_create_attestor(): # Create a client - client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client() + client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient() # Initialize request argument(s) attestor = binaryauthorization_v1beta1.Attestor() @@ -509,7 +516,7 @@ def sample_create_attestor(): ) # Make the request - response = client.create_attestor(request=request) + response = await client.create_attestor(request=request) # Handle the response print(response) @@ -593,7 +600,12 @@ def sample_create_attestor(): ) # 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 @@ -613,14 +625,13 @@ async def get_attestor( [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 - def sample_get_attestor(): + async def sample_get_attestor(): # Create a client - client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client() + client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1beta1.GetAttestorRequest( @@ -628,7 +639,7 @@ def sample_get_attestor(): ) # Make the request - response = client.get_attestor(request=request) + response = await client.get_attestor(request=request) # Handle the response print(response) @@ -700,7 +711,12 @@ def sample_get_attestor(): ) # 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 @@ -720,14 +736,13 @@ async def update_attestor( [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 - def sample_update_attestor(): + async def sample_update_attestor(): # Create a client - client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client() + client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient() # Initialize request argument(s) attestor = binaryauthorization_v1beta1.Attestor() @@ -739,7 +754,7 @@ def sample_update_attestor(): ) # Make the request - response = client.update_attestor(request=request) + response = await client.update_attestor(request=request) # Handle the response print(response) @@ -816,7 +831,12 @@ def sample_update_attestor(): ) # 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 @@ -834,14 +854,13 @@ async def list_attestors( [attestors][google.cloud.binaryauthorization.v1beta1.Attestor]. Returns INVALID_ARGUMENT if the project does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 - def sample_list_attestors(): + async def sample_list_attestors(): # Create a client - client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client() + client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1beta1.ListAttestorsRequest( @@ -852,7 +871,7 @@ def sample_list_attestors(): page_result = client.list_attestors(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -925,12 +944,20 @@ def sample_list_attestors(): ) # 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.ListAttestorsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -951,14 +978,13 @@ async def delete_attestor( [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 - def sample_delete_attestor(): + async def sample_delete_attestor(): # Create a client - client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client() + client = binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1beta1.DeleteAttestorRequest( @@ -966,7 +992,7 @@ def sample_delete_attestor(): ) # Make the request - client.delete_attestor(request=request) + await client.delete_attestor(request=request) Args: request (Union[google.cloud.binaryauthorization_v1beta1.types.DeleteAttestorRequest, dict]): @@ -1029,7 +1055,10 @@ def sample_delete_attestor(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def __aenter__(self): diff --git a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py index 7e2a9fa..170f7d4 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py +++ b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/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 @@ -67,7 +67,8 @@ class BinauthzManagementServiceV1Beta1ClientMeta(type): ] = BinauthzManagementServiceV1Beta1GrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[BinauthzManagementServiceV1Beta1Transport]: """Returns an appropriate transport class. @@ -182,10 +183,14 @@ def transport(self) -> BinauthzManagementServiceV1Beta1Transport: return self._transport @staticmethod - def attestor_path(project: str, attestor: str,) -> str: + def attestor_path( + project: str, + attestor: str, + ) -> str: """Returns a fully-qualified attestor string.""" return "projects/{project}/attestors/{attestor}".format( - project=project, attestor=attestor, + project=project, + attestor=attestor, ) @staticmethod @@ -195,9 +200,13 @@ def parse_attestor_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def policy_path(project: str,) -> str: + def policy_path( + project: str, + ) -> str: """Returns a fully-qualified policy string.""" - return "projects/{project}/policy".format(project=project,) + return "projects/{project}/policy".format( + project=project, + ) @staticmethod def parse_policy_path(path: str) -> Dict[str, str]: @@ -206,7 +215,9 @@ def parse_policy_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, @@ -219,9 +230,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]: @@ -230,9 +245,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]: @@ -241,9 +260,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]: @@ -252,10 +275,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 @@ -452,7 +479,6 @@ def get_policy( [policy][google.cloud.binaryauthorization.v1beta1.Policy] if the project does not have one. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 @@ -529,7 +555,12 @@ def sample_get_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -552,7 +583,6 @@ def update_policy( Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 @@ -638,7 +668,12 @@ def sample_update_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -664,7 +699,6 @@ def create_attestor( [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] already exists. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 @@ -769,7 +803,12 @@ def sample_create_attestor(): ) # 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 @@ -789,7 +828,6 @@ def get_attestor( [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 @@ -866,7 +904,12 @@ def sample_get_attestor(): ) # 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 @@ -886,7 +929,6 @@ def update_attestor( [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 @@ -972,7 +1014,12 @@ def sample_update_attestor(): ) # 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 @@ -990,7 +1037,6 @@ def list_attestors( [attestors][google.cloud.binaryauthorization.v1beta1.Attestor]. Returns INVALID_ARGUMENT if the project does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 @@ -1071,12 +1117,20 @@ def sample_list_attestors(): ) # 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.ListAttestorsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1097,7 +1151,6 @@ def delete_attestor( [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] does not exist. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 @@ -1165,7 +1218,10 @@ def sample_delete_attestor(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def __enter__(self): diff --git a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py index dd724ae..0968b6b 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py +++ b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py @@ -82,6 +82,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" @@ -153,7 +154,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_attestor: gapic_v1.method.wrap_method( - self.create_attestor, default_timeout=600.0, client_info=client_info, + self.create_attestor, + default_timeout=600.0, + client_info=client_info, ), self.get_attestor: gapic_v1.method.wrap_method( self.get_attestor, @@ -220,9 +223,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() @@ -288,5 +291,9 @@ def delete_attestor( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("BinauthzManagementServiceV1Beta1Transport",) diff --git a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py index f89bb42..ab98529 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py +++ b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py @@ -234,8 +234,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 @@ -462,5 +461,9 @@ def delete_attestor( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("BinauthzManagementServiceV1Beta1GrpcTransport",) diff --git a/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/async_client.py b/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/async_client.py index c5319ae..417a156 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/async_client.py +++ b/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/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 @@ -216,14 +216,13 @@ async def get_system_policy( r"""Gets the current system policy in the specified location. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 - def sample_get_system_policy(): + async def sample_get_system_policy(): # Create a client - client = binaryauthorization_v1beta1.SystemPolicyV1Beta1Client() + client = binaryauthorization_v1beta1.SystemPolicyV1Beta1AsyncClient() # Initialize request argument(s) request = binaryauthorization_v1beta1.GetSystemPolicyRequest( @@ -231,7 +230,7 @@ def sample_get_system_policy(): ) # Make the request - response = client.get_system_policy(request=request) + response = await client.get_system_policy(request=request) # Handle the response print(response) @@ -293,7 +292,12 @@ def sample_get_system_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/client.py b/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/client.py index 9195fca..0716134 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/client.py +++ b/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/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 @@ -57,7 +57,8 @@ class SystemPolicyV1Beta1ClientMeta(type): _transport_registry["grpc_asyncio"] = SystemPolicyV1Beta1GrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[SystemPolicyV1Beta1Transport]: """Returns an appropriate transport class. @@ -163,9 +164,13 @@ def transport(self) -> SystemPolicyV1Beta1Transport: return self._transport @staticmethod - def policy_path(project: str,) -> str: + def policy_path( + project: str, + ) -> str: """Returns a fully-qualified policy string.""" - return "projects/{project}/policy".format(project=project,) + return "projects/{project}/policy".format( + project=project, + ) @staticmethod def parse_policy_path(path: str) -> Dict[str, str]: @@ -174,7 +179,9 @@ def parse_policy_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, @@ -187,9 +194,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]: @@ -198,9 +209,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]: @@ -209,9 +224,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]: @@ -220,10 +239,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 @@ -409,7 +432,6 @@ def get_system_policy( r"""Gets the current system policy in the specified location. - .. code-block:: python from google.cloud import binaryauthorization_v1beta1 @@ -486,7 +508,12 @@ def sample_get_system_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/base.py b/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/base.py index c770144..23a225b 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/base.py +++ b/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/base.py @@ -81,6 +81,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,16 +123,18 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.get_system_policy: gapic_v1.method.wrap_method( - self.get_system_policy, default_timeout=None, client_info=client_info, + self.get_system_policy, + default_timeout=None, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -144,5 +147,9 @@ def get_system_policy( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("SystemPolicyV1Beta1Transport",) diff --git a/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc.py b/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc.py index 0d5d12a..d3cb249 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc.py +++ b/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc.py @@ -225,8 +225,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 @@ -259,5 +258,9 @@ def get_system_policy( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("SystemPolicyV1Beta1GrpcTransport",) diff --git a/google/cloud/binaryauthorization_v1beta1/types/__init__.py b/google/cloud/binaryauthorization_v1beta1/types/__init__.py index 30b8ea4..25e8b6c 100644 --- a/google/cloud/binaryauthorization_v1beta1/types/__init__.py +++ b/google/cloud/binaryauthorization_v1beta1/types/__init__.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .continuous_validation_logging import ContinuousValidationEvent +from .continuous_validation_logging import ( + ContinuousValidationEvent, +) from .resources import ( AdmissionRule, AdmissionWhitelistPattern, diff --git a/google/cloud/binaryauthorization_v1beta1/types/continuous_validation_logging.py b/google/cloud/binaryauthorization_v1beta1/types/continuous_validation_logging.py index d197207..f3a1f49 100644 --- a/google/cloud/binaryauthorization_v1beta1/types/continuous_validation_logging.py +++ b/google/cloud/binaryauthorization_v1beta1/types/continuous_validation_logging.py @@ -20,7 +20,9 @@ __protobuf__ = proto.module( package="google.cloud.binaryauthorization.v1beta1", - manifest={"ContinuousValidationEvent",}, + manifest={ + "ContinuousValidationEvent", + }, ) @@ -85,20 +87,33 @@ class AuditResult(proto.Enum): ALLOW = 1 DENY = 2 - image = proto.Field(proto.STRING, number=1,) + image = proto.Field( + proto.STRING, + number=1, + ) result = proto.Field( proto.ENUM, number=2, enum="ContinuousValidationEvent.ContinuousValidationPodEvent.ImageDetails.AuditResult", ) - description = proto.Field(proto.STRING, number=3,) + description = proto.Field( + proto.STRING, + number=3, + ) - pod = proto.Field(proto.STRING, number=1,) + pod = proto.Field( + proto.STRING, + number=1, + ) deploy_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, ) end_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, ) verdict = proto.Field( proto.ENUM, @@ -120,7 +135,10 @@ class UnsupportedPolicyEvent(proto.Message): A description of the unsupported policy. """ - description = proto.Field(proto.STRING, number=1,) + description = proto.Field( + proto.STRING, + number=1, + ) pod_event = proto.Field( proto.MESSAGE, @@ -129,7 +147,10 @@ class UnsupportedPolicyEvent(proto.Message): message=ContinuousValidationPodEvent, ) unsupported_policy_event = proto.Field( - proto.MESSAGE, number=2, oneof="event_type", message=UnsupportedPolicyEvent, + proto.MESSAGE, + number=2, + oneof="event_type", + message=UnsupportedPolicyEvent, ) diff --git a/google/cloud/binaryauthorization_v1beta1/types/resources.py b/google/cloud/binaryauthorization_v1beta1/types/resources.py index 7b57bbc..0fd403e 100644 --- a/google/cloud/binaryauthorization_v1beta1/types/resources.py +++ b/google/cloud/binaryauthorization_v1beta1/types/resources.py @@ -57,21 +57,21 @@ class Policy(proto.Message): permitted. This feature is typically used to exclude Google or third-party infrastructure images from Binary Authorization policies. - cluster_admission_rules (Sequence[google.cloud.binaryauthorization_v1beta1.types.Policy.ClusterAdmissionRulesEntry]): + cluster_admission_rules (Mapping[str, google.cloud.binaryauthorization_v1beta1.types.AdmissionRule]): Optional. Per-cluster admission rules. Cluster spec format: ``location.clusterId``. There can be at most one admission rule per cluster spec. A ``location`` is either a compute zone (e.g. us-central1-a) or a region (e.g. us-central1). For ``clusterId`` syntax restrictions see https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters. - kubernetes_namespace_admission_rules (Sequence[google.cloud.binaryauthorization_v1beta1.types.Policy.KubernetesNamespaceAdmissionRulesEntry]): + kubernetes_namespace_admission_rules (Mapping[str, google.cloud.binaryauthorization_v1beta1.types.AdmissionRule]): Optional. Per-kubernetes-namespace admission rules. K8s namespace spec format: ``[a-z.-]+``, e.g. ``some-namespace`` - kubernetes_service_account_admission_rules (Sequence[google.cloud.binaryauthorization_v1beta1.types.Policy.KubernetesServiceAccountAdmissionRulesEntry]): + kubernetes_service_account_admission_rules (Mapping[str, google.cloud.binaryauthorization_v1beta1.types.AdmissionRule]): Optional. Per-kubernetes-service-account admission rules. Service account spec format: ``namespace:serviceaccount``. e.g. ``test-ns:default`` - istio_service_identity_admission_rules (Sequence[google.cloud.binaryauthorization_v1beta1.types.Policy.IstioServiceIdentityAdmissionRulesEntry]): + istio_service_identity_admission_rules (Mapping[str, google.cloud.binaryauthorization_v1beta1.types.AdmissionRule]): Optional. Per-istio-service-identity admission rules. Istio service identity spec format: ``spiffe:///ns//sa/`` or @@ -93,30 +93,58 @@ class GlobalPolicyEvaluationMode(proto.Enum): ENABLE = 1 DISABLE = 2 - name = proto.Field(proto.STRING, number=1,) - description = proto.Field(proto.STRING, number=6,) + name = proto.Field( + proto.STRING, + number=1, + ) + description = proto.Field( + proto.STRING, + number=6, + ) global_policy_evaluation_mode = proto.Field( - proto.ENUM, number=7, enum=GlobalPolicyEvaluationMode, + proto.ENUM, + number=7, + enum=GlobalPolicyEvaluationMode, ) admission_whitelist_patterns = proto.RepeatedField( - proto.MESSAGE, number=2, message="AdmissionWhitelistPattern", + proto.MESSAGE, + number=2, + message="AdmissionWhitelistPattern", ) cluster_admission_rules = proto.MapField( - proto.STRING, proto.MESSAGE, number=3, message="AdmissionRule", + proto.STRING, + proto.MESSAGE, + number=3, + message="AdmissionRule", ) kubernetes_namespace_admission_rules = proto.MapField( - proto.STRING, proto.MESSAGE, number=10, message="AdmissionRule", + proto.STRING, + proto.MESSAGE, + number=10, + message="AdmissionRule", ) kubernetes_service_account_admission_rules = proto.MapField( - proto.STRING, proto.MESSAGE, number=8, message="AdmissionRule", + proto.STRING, + proto.MESSAGE, + number=8, + message="AdmissionRule", ) istio_service_identity_admission_rules = proto.MapField( - proto.STRING, proto.MESSAGE, number=9, message="AdmissionRule", + proto.STRING, + proto.MESSAGE, + number=9, + message="AdmissionRule", ) default_admission_rule = proto.Field( - proto.MESSAGE, number=4, message="AdmissionRule", + proto.MESSAGE, + number=4, + message="AdmissionRule", + ) + update_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, ) - update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) class AdmissionWhitelistPattern(proto.Message): @@ -137,7 +165,10 @@ class AdmissionWhitelistPattern(proto.Message): i.e., ``gcr.io/nginx**`` matches ``gcr.io/nginx/image``. """ - name_pattern = proto.Field(proto.STRING, number=1,) + name_pattern = proto.Field( + proto.STRING, + number=1, + ) class AdmissionRule(proto.Message): @@ -189,9 +220,20 @@ class EnforcementMode(proto.Enum): ENFORCED_BLOCK_AND_AUDIT_LOG = 1 DRYRUN_AUDIT_LOG_ONLY = 2 - evaluation_mode = proto.Field(proto.ENUM, number=1, enum=EvaluationMode,) - require_attestations_by = proto.RepeatedField(proto.STRING, number=2,) - enforcement_mode = proto.Field(proto.ENUM, number=3, enum=EnforcementMode,) + evaluation_mode = proto.Field( + proto.ENUM, + number=1, + enum=EvaluationMode, + ) + require_attestations_by = proto.RepeatedField( + proto.STRING, + number=2, + ) + enforcement_mode = proto.Field( + proto.ENUM, + number=3, + enum=EnforcementMode, + ) class Attestor(proto.Message): @@ -219,12 +261,25 @@ class Attestor(proto.Message): updated. """ - name = proto.Field(proto.STRING, number=1,) - description = proto.Field(proto.STRING, number=6,) + name = proto.Field( + proto.STRING, + number=1, + ) + description = proto.Field( + proto.STRING, + number=6, + ) user_owned_drydock_note = proto.Field( - proto.MESSAGE, number=3, oneof="attestor_type", message="UserOwnedDrydockNote", + proto.MESSAGE, + number=3, + oneof="attestor_type", + message="UserOwnedDrydockNote", + ) + update_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, ) - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) class UserOwnedDrydockNote(proto.Message): @@ -268,11 +323,19 @@ class UserOwnedDrydockNote(proto.Message): email based on a different naming pattern. """ - note_reference = proto.Field(proto.STRING, number=1,) + note_reference = proto.Field( + proto.STRING, + number=1, + ) public_keys = proto.RepeatedField( - proto.MESSAGE, number=2, message="AttestorPublicKey", + proto.MESSAGE, + number=2, + message="AttestorPublicKey", + ) + delegation_service_account_email = proto.Field( + proto.STRING, + number=3, ) - delegation_service_account_email = proto.Field(proto.STRING, number=3,) class PkixPublicKey(proto.Message): @@ -319,8 +382,15 @@ class SignatureAlgorithm(proto.Enum): ECDSA_P521_SHA512 = 11 EC_SIGN_P521_SHA512 = 11 - public_key_pem = proto.Field(proto.STRING, number=1,) - signature_algorithm = proto.Field(proto.ENUM, number=2, enum=SignatureAlgorithm,) + public_key_pem = proto.Field( + proto.STRING, + number=1, + ) + signature_algorithm = proto.Field( + proto.ENUM, + number=2, + enum=SignatureAlgorithm, + ) class AttestorPublicKey(proto.Message): @@ -370,13 +440,24 @@ class AttestorPublicKey(proto.Message): This field is a member of `oneof`_ ``public_key``. """ - comment = proto.Field(proto.STRING, number=1,) - id = proto.Field(proto.STRING, number=2,) + comment = proto.Field( + proto.STRING, + number=1, + ) + id = proto.Field( + proto.STRING, + number=2, + ) ascii_armored_pgp_public_key = proto.Field( - proto.STRING, number=3, oneof="public_key", + proto.STRING, + number=3, + oneof="public_key", ) pkix_public_key = proto.Field( - proto.MESSAGE, number=5, oneof="public_key", message="PkixPublicKey", + proto.MESSAGE, + number=5, + oneof="public_key", + message="PkixPublicKey", ) diff --git a/google/cloud/binaryauthorization_v1beta1/types/service.py b/google/cloud/binaryauthorization_v1beta1/types/service.py index 44fb077..a2ea946 100644 --- a/google/cloud/binaryauthorization_v1beta1/types/service.py +++ b/google/cloud/binaryauthorization_v1beta1/types/service.py @@ -44,7 +44,10 @@ class GetPolicyRequest(proto.Message): retrieve, in the format ``projects/*/policy``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdatePolicyRequest(proto.Message): @@ -60,7 +63,11 @@ class UpdatePolicyRequest(proto.Message): format ``projects/*/policy``. """ - policy = proto.Field(proto.MESSAGE, number=1, message=resources.Policy,) + policy = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Policy, + ) class CreateAttestorRequest(proto.Message): @@ -83,9 +90,19 @@ class CreateAttestorRequest(proto.Message): ``projects/*/attestors/*``. """ - parent = proto.Field(proto.STRING, number=1,) - attestor_id = proto.Field(proto.STRING, number=2,) - attestor = proto.Field(proto.MESSAGE, number=3, message=resources.Attestor,) + parent = proto.Field( + proto.STRING, + number=1, + ) + attestor_id = proto.Field( + proto.STRING, + number=2, + ) + attestor = proto.Field( + proto.MESSAGE, + number=3, + message=resources.Attestor, + ) class GetAttestorRequest(proto.Message): @@ -98,7 +115,10 @@ class GetAttestorRequest(proto.Message): to retrieve, in the format ``projects/*/attestors/*``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdateAttestorRequest(proto.Message): @@ -114,7 +134,11 @@ class UpdateAttestorRequest(proto.Message): format ``projects/*/attestors/*``. """ - attestor = proto.Field(proto.MESSAGE, number=1, message=resources.Attestor,) + attestor = proto.Field( + proto.MESSAGE, + number=1, + message=resources.Attestor, + ) class ListAttestorsRequest(proto.Message): @@ -138,9 +162,18 @@ class ListAttestorsRequest(proto.Message): method. """ - 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 ListAttestorsResponse(proto.Message): @@ -163,9 +196,14 @@ def raw_page(self): return self attestors = proto.RepeatedField( - proto.MESSAGE, number=1, message=resources.Attestor, + proto.MESSAGE, + number=1, + message=resources.Attestor, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class DeleteAttestorRequest(proto.Message): @@ -178,7 +216,10 @@ class DeleteAttestorRequest(proto.Message): to delete, in the format ``projects/*/attestors/*``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class GetSystemPolicyRequest(proto.Message): @@ -191,7 +232,10 @@ class GetSystemPolicyRequest(proto.Message): associated with a project. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c..92da31f 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 c230db9..4b3d533 100644 --- a/owlbot.py +++ b/owlbot.py @@ -77,4 +77,6 @@ excludes=[".coveragerc"], # the microgenerator has a good coveragerc file ) +python.configure_previous_major_version_branches() + s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/samples/generated_samples/snippet_metadata_binaryauthorization_v1.json b/samples/generated_samples/snippet_metadata_binaryauthorization_v1.json index 5f748e4..e135974 100644 --- a/samples/generated_samples/snippet_metadata_binaryauthorization_v1.json +++ b/samples/generated_samples/snippet_metadata_binaryauthorization_v1.json @@ -1,16 +1,69 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.binaryauthorization.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-binaryauthorization" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient", + "shortName": "BinauthzManagementServiceV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient.create_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.CreateAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "CreateAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.CreateAttestorRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "attestor_id", + "type": "str" + }, + { + "name": "attestor", + "type": "google.cloud.binaryauthorization_v1.types.Attestor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", + "shortName": "create_attestor" }, + "description": "Sample for CreateAttestor", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_create_attestor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_CreateAttestor_async", "segments": [ { @@ -43,18 +96,62 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_create_attestor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client", + "shortName": "BinauthzManagementServiceV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.create_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.CreateAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "CreateAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.CreateAttestorRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "attestor_id", + "type": "str" + }, + { + "name": "attestor", + "type": "google.cloud.binaryauthorization_v1.types.Attestor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", + "shortName": "create_attestor" }, + "description": "Sample for CreateAttestor", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_create_attestor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_CreateAttestor_sync", "segments": [ { @@ -87,19 +184,54 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_create_attestor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient", + "shortName": "BinauthzManagementServiceV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient.delete_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.DeleteAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "DeleteAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.DeleteAttestorRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_attestor" }, + "description": "Sample for DeleteAttestor", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_delete_attestor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_DeleteAttestor_async", "segments": [ { @@ -130,18 +262,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_delete_attestor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client", + "shortName": "BinauthzManagementServiceV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.delete_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.DeleteAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "DeleteAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.DeleteAttestorRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_attestor" }, + "description": "Sample for DeleteAttestor", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_delete_attestor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_DeleteAttestor_sync", "segments": [ { @@ -172,19 +339,55 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_delete_attestor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient", + "shortName": "BinauthzManagementServiceV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient.get_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.GetAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "GetAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.GetAttestorRequest" + }, + { + "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.binaryauthorization_v1.types.Attestor", + "shortName": "get_attestor" }, + "description": "Sample for GetAttestor", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_get_attestor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_GetAttestor_async", "segments": [ { @@ -217,18 +420,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_get_attestor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client", + "shortName": "BinauthzManagementServiceV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.get_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.GetAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "GetAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.GetAttestorRequest" + }, + { + "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.binaryauthorization_v1.types.Attestor", + "shortName": "get_attestor" }, + "description": "Sample for GetAttestor", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_get_attestor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_GetAttestor_sync", "segments": [ { @@ -261,19 +500,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_get_attestor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient", + "shortName": "BinauthzManagementServiceV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient.get_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.GetPolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "GetPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.GetPolicyRequest" + }, + { + "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.binaryauthorization_v1.types.Policy", + "shortName": "get_policy" }, + "description": "Sample for GetPolicy", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_get_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_GetPolicy_async", "segments": [ { @@ -306,18 +581,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_get_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client", + "shortName": "BinauthzManagementServiceV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.get_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.GetPolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "GetPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.GetPolicyRequest" + }, + { + "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.binaryauthorization_v1.types.Policy", + "shortName": "get_policy" }, + "description": "Sample for GetPolicy", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_get_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_GetPolicy_sync", "segments": [ { @@ -350,19 +661,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_get_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient", + "shortName": "BinauthzManagementServiceV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient.list_attestors", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.ListAttestors", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "ListAttestors" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.ListAttestorsRequest" + }, + { + "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.binaryauthorization_v1.services.binauthz_management_service_v1.pagers.ListAttestorsAsyncPager", + "shortName": "list_attestors" }, + "description": "Sample for ListAttestors", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_list_attestors_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_ListAttestors_async", "segments": [ { @@ -395,18 +742,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_list_attestors_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client", + "shortName": "BinauthzManagementServiceV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.list_attestors", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.ListAttestors", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "ListAttestors" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.ListAttestorsRequest" + }, + { + "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.binaryauthorization_v1.services.binauthz_management_service_v1.pagers.ListAttestorsPager", + "shortName": "list_attestors" }, + "description": "Sample for ListAttestors", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_list_attestors_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_ListAttestors_sync", "segments": [ { @@ -439,19 +822,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_list_attestors_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient", + "shortName": "BinauthzManagementServiceV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient.update_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.UpdateAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "UpdateAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.UpdateAttestorRequest" + }, + { + "name": "attestor", + "type": "google.cloud.binaryauthorization_v1.types.Attestor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", + "shortName": "update_attestor" }, + "description": "Sample for UpdateAttestor", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_update_attestor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_UpdateAttestor_async", "segments": [ { @@ -484,18 +903,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_update_attestor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client", + "shortName": "BinauthzManagementServiceV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.update_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.UpdateAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "UpdateAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.UpdateAttestorRequest" + }, + { + "name": "attestor", + "type": "google.cloud.binaryauthorization_v1.types.Attestor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", + "shortName": "update_attestor" }, + "description": "Sample for UpdateAttestor", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_update_attestor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_UpdateAttestor_sync", "segments": [ { @@ -528,19 +983,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_update_attestor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient", + "shortName": "BinauthzManagementServiceV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient.update_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.UpdatePolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "UpdatePolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.UpdatePolicyRequest" + }, + { + "name": "policy", + "type": "google.cloud.binaryauthorization_v1.types.Policy" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1.types.Policy", + "shortName": "update_policy" }, + "description": "Sample for UpdatePolicy", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_update_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_UpdatePolicy_async", "segments": [ { @@ -573,18 +1064,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_update_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client", + "shortName": "BinauthzManagementServiceV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.update_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1.UpdatePolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", "shortName": "BinauthzManagementServiceV1" }, "shortName": "UpdatePolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.UpdatePolicyRequest" + }, + { + "name": "policy", + "type": "google.cloud.binaryauthorization_v1.types.Policy" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1.types.Policy", + "shortName": "update_policy" }, + "description": "Sample for UpdatePolicy", "file": "binaryauthorization_v1_generated_binauthz_management_service_v1_update_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_BinauthzManagementServiceV1_UpdatePolicy_sync", "segments": [ { @@ -617,19 +1144,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_binauthz_management_service_v1_update_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.SystemPolicyV1AsyncClient", + "shortName": "SystemPolicyV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.SystemPolicyV1AsyncClient.get_system_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1.SystemPolicyV1.GetSystemPolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1.SystemPolicyV1", "shortName": "SystemPolicyV1" }, "shortName": "GetSystemPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.GetSystemPolicyRequest" + }, + { + "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.binaryauthorization_v1.types.Policy", + "shortName": "get_system_policy" }, + "description": "Sample for GetSystemPolicy", "file": "binaryauthorization_v1_generated_system_policy_v1_get_system_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_SystemPolicyV1_GetSystemPolicy_async", "segments": [ { @@ -662,18 +1225,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_system_policy_v1_get_system_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.SystemPolicyV1Client", + "shortName": "SystemPolicyV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.SystemPolicyV1Client.get_system_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1.SystemPolicyV1.GetSystemPolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1.SystemPolicyV1", "shortName": "SystemPolicyV1" }, "shortName": "GetSystemPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.GetSystemPolicyRequest" + }, + { + "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.binaryauthorization_v1.types.Policy", + "shortName": "get_system_policy" }, + "description": "Sample for GetSystemPolicy", "file": "binaryauthorization_v1_generated_system_policy_v1_get_system_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_SystemPolicyV1_GetSystemPolicy_sync", "segments": [ { @@ -706,19 +1305,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_system_policy_v1_get_system_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1.ValidationHelperV1AsyncClient", + "shortName": "ValidationHelperV1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1.ValidationHelperV1AsyncClient.validate_attestation_occurrence", "method": { + "fullName": "google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence", "service": { + "fullName": "google.cloud.binaryauthorization.v1.ValidationHelperV1", "shortName": "ValidationHelperV1" }, "shortName": "ValidateAttestationOccurrence" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceResponse", + "shortName": "validate_attestation_occurrence" }, + "description": "Sample for ValidateAttestationOccurrence", "file": "binaryauthorization_v1_generated_validation_helper_v1_validate_attestation_occurrence_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_ValidationHelperV1_ValidateAttestationOccurrence_async", "segments": [ { @@ -751,18 +1382,50 @@ "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_validation_helper_v1_validate_attestation_occurrence_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1.ValidationHelperV1Client", + "shortName": "ValidationHelperV1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1.ValidationHelperV1Client.validate_attestation_occurrence", "method": { + "fullName": "google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence", "service": { + "fullName": "google.cloud.binaryauthorization.v1.ValidationHelperV1", "shortName": "ValidationHelperV1" }, "shortName": "ValidateAttestationOccurrence" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceResponse", + "shortName": "validate_attestation_occurrence" }, + "description": "Sample for ValidateAttestationOccurrence", "file": "binaryauthorization_v1_generated_validation_helper_v1_validate_attestation_occurrence_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1_generated_ValidationHelperV1_ValidateAttestationOccurrence_sync", "segments": [ { @@ -795,7 +1458,8 @@ "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1_generated_validation_helper_v1_validate_attestation_occurrence_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_binaryauthorization_v1beta1.json b/samples/generated_samples/snippet_metadata_binaryauthorization_v1beta1.json index b42f297..3845e43 100644 --- a/samples/generated_samples/snippet_metadata_binaryauthorization_v1beta1.json +++ b/samples/generated_samples/snippet_metadata_binaryauthorization_v1beta1.json @@ -1,16 +1,69 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.binaryauthorization.v1beta1", + "version": "v1beta1" + } + ], + "language": "PYTHON", + "name": "google-cloud-binaryauthorization" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient", + "shortName": "BinauthzManagementServiceV1Beta1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient.create_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.CreateAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "CreateAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.CreateAttestorRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "attestor_id", + "type": "str" + }, + { + "name": "attestor", + "type": "google.cloud.binaryauthorization_v1beta1.types.Attestor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", + "shortName": "create_attestor" }, + "description": "Sample for CreateAttestor", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_create_attestor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_CreateAttestor_async", "segments": [ { @@ -43,18 +96,62 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_create_attestor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client", + "shortName": "BinauthzManagementServiceV1Beta1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.create_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.CreateAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "CreateAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.CreateAttestorRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "attestor_id", + "type": "str" + }, + { + "name": "attestor", + "type": "google.cloud.binaryauthorization_v1beta1.types.Attestor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", + "shortName": "create_attestor" }, + "description": "Sample for CreateAttestor", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_create_attestor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_CreateAttestor_sync", "segments": [ { @@ -87,19 +184,54 @@ "start": 48, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_create_attestor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient", + "shortName": "BinauthzManagementServiceV1Beta1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient.delete_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.DeleteAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "DeleteAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.DeleteAttestorRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_attestor" }, + "description": "Sample for DeleteAttestor", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_delete_attestor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_DeleteAttestor_async", "segments": [ { @@ -130,18 +262,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_delete_attestor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client", + "shortName": "BinauthzManagementServiceV1Beta1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.delete_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.DeleteAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "DeleteAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.DeleteAttestorRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_attestor" }, + "description": "Sample for DeleteAttestor", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_delete_attestor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_DeleteAttestor_sync", "segments": [ { @@ -172,19 +339,55 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_delete_attestor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient", + "shortName": "BinauthzManagementServiceV1Beta1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient.get_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.GetAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "GetAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.GetAttestorRequest" + }, + { + "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.binaryauthorization_v1beta1.types.Attestor", + "shortName": "get_attestor" }, + "description": "Sample for GetAttestor", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_get_attestor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_GetAttestor_async", "segments": [ { @@ -217,18 +420,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_get_attestor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client", + "shortName": "BinauthzManagementServiceV1Beta1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.get_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.GetAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "GetAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.GetAttestorRequest" + }, + { + "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.binaryauthorization_v1beta1.types.Attestor", + "shortName": "get_attestor" }, + "description": "Sample for GetAttestor", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_get_attestor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_GetAttestor_sync", "segments": [ { @@ -261,19 +500,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_get_attestor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient", + "shortName": "BinauthzManagementServiceV1Beta1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient.get_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.GetPolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "GetPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.GetPolicyRequest" + }, + { + "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.binaryauthorization_v1beta1.types.Policy", + "shortName": "get_policy" }, + "description": "Sample for GetPolicy", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_get_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_GetPolicy_async", "segments": [ { @@ -306,18 +581,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_get_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client", + "shortName": "BinauthzManagementServiceV1Beta1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.get_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.GetPolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "GetPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.GetPolicyRequest" + }, + { + "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.binaryauthorization_v1beta1.types.Policy", + "shortName": "get_policy" }, + "description": "Sample for GetPolicy", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_get_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_GetPolicy_sync", "segments": [ { @@ -350,19 +661,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_get_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient", + "shortName": "BinauthzManagementServiceV1Beta1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient.list_attestors", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.ListAttestors", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "ListAttestors" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.ListAttestorsRequest" + }, + { + "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.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1.pagers.ListAttestorsAsyncPager", + "shortName": "list_attestors" }, + "description": "Sample for ListAttestors", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_list_attestors_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_ListAttestors_async", "segments": [ { @@ -395,18 +742,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_list_attestors_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client", + "shortName": "BinauthzManagementServiceV1Beta1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.list_attestors", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.ListAttestors", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "ListAttestors" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.ListAttestorsRequest" + }, + { + "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.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1.pagers.ListAttestorsPager", + "shortName": "list_attestors" }, + "description": "Sample for ListAttestors", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_list_attestors_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_ListAttestors_sync", "segments": [ { @@ -439,19 +822,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_list_attestors_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient", + "shortName": "BinauthzManagementServiceV1Beta1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient.update_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.UpdateAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "UpdateAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.UpdateAttestorRequest" + }, + { + "name": "attestor", + "type": "google.cloud.binaryauthorization_v1beta1.types.Attestor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", + "shortName": "update_attestor" }, + "description": "Sample for UpdateAttestor", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_update_attestor_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_UpdateAttestor_async", "segments": [ { @@ -484,18 +903,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_update_attestor_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client", + "shortName": "BinauthzManagementServiceV1Beta1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.update_attestor", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.UpdateAttestor", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "UpdateAttestor" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.UpdateAttestorRequest" + }, + { + "name": "attestor", + "type": "google.cloud.binaryauthorization_v1beta1.types.Attestor" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", + "shortName": "update_attestor" }, + "description": "Sample for UpdateAttestor", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_update_attestor_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_UpdateAttestor_sync", "segments": [ { @@ -528,19 +983,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_update_attestor_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient", + "shortName": "BinauthzManagementServiceV1Beta1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient.update_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.UpdatePolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "UpdatePolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.UpdatePolicyRequest" + }, + { + "name": "policy", + "type": "google.cloud.binaryauthorization_v1beta1.types.Policy" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1beta1.types.Policy", + "shortName": "update_policy" }, + "description": "Sample for UpdatePolicy", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_update_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_UpdatePolicy_async", "segments": [ { @@ -573,18 +1064,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_update_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client", + "shortName": "BinauthzManagementServiceV1Beta1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.update_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1.UpdatePolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", "shortName": "BinauthzManagementServiceV1Beta1" }, "shortName": "UpdatePolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.UpdatePolicyRequest" + }, + { + "name": "policy", + "type": "google.cloud.binaryauthorization_v1beta1.types.Policy" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.binaryauthorization_v1beta1.types.Policy", + "shortName": "update_policy" }, + "description": "Sample for UpdatePolicy", "file": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_update_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_BinauthzManagementServiceV1Beta1_UpdatePolicy_sync", "segments": [ { @@ -617,19 +1144,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_binauthz_management_service_v1_beta1_update_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.SystemPolicyV1Beta1AsyncClient", + "shortName": "SystemPolicyV1Beta1AsyncClient" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.SystemPolicyV1Beta1AsyncClient.get_system_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1.GetSystemPolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1", "shortName": "SystemPolicyV1Beta1" }, "shortName": "GetSystemPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.GetSystemPolicyRequest" + }, + { + "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.binaryauthorization_v1beta1.types.Policy", + "shortName": "get_system_policy" }, + "description": "Sample for GetSystemPolicy", "file": "binaryauthorization_v1beta1_generated_system_policy_v1_beta1_get_system_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_SystemPolicyV1Beta1_GetSystemPolicy_async", "segments": [ { @@ -662,18 +1225,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_system_policy_v1_beta1_get_system_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.binaryauthorization_v1beta1.SystemPolicyV1Beta1Client", + "shortName": "SystemPolicyV1Beta1Client" + }, + "fullName": "google.cloud.binaryauthorization_v1beta1.SystemPolicyV1Beta1Client.get_system_policy", "method": { + "fullName": "google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1.GetSystemPolicy", "service": { + "fullName": "google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1", "shortName": "SystemPolicyV1Beta1" }, "shortName": "GetSystemPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.binaryauthorization_v1beta1.types.GetSystemPolicyRequest" + }, + { + "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.binaryauthorization_v1beta1.types.Policy", + "shortName": "get_system_policy" }, + "description": "Sample for GetSystemPolicy", "file": "binaryauthorization_v1beta1_generated_system_policy_v1_beta1_get_system_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "binaryauthorization_v1beta1_generated_SystemPolicyV1Beta1_GetSystemPolicy_sync", "segments": [ { @@ -706,7 +1305,8 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "binaryauthorization_v1beta1_generated_system_policy_v1_beta1_get_system_policy_sync.py" } ] } diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e..91b5967 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 9b0178d..b0bf079 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ import setuptools # type: ignore -version = "1.2.2" +version = "1.2.3" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -50,8 +50,9 @@ # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", - "proto-plus >= 1.15.0", - "grafeas >= 1.1.2", + "proto-plus >= 1.15.0, <2.0.0dev", + "protobuf >= 3.19.0, <4.0.0dev", + "grafeas >= 1.1.2, <2.0dev", ), python_requires=">=3.6", classifiers=[ diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 71a1281..ca3c4ca 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -7,3 +7,4 @@ google-api-core==1.31.5 proto-plus==1.15.0 grafeas==1.1.2 +protobuf==3.19.0 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index da93009..ca3c4ca 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -1,2 +1,10 @@ -# This constraints file is left inentionally empty -# so the latest version of dependencies is installed \ No newline at end of file +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.31.5 +proto-plus==1.15.0 +grafeas==1.1.2 +protobuf==3.19.0 diff --git a/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py b/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py index d6b257b..e98a7ce 100644 --- a/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py +++ b/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -98,21 +104,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", - [BinauthzManagementServiceV1Client, BinauthzManagementServiceV1AsyncClient,], + "client_class,transport_name", + [ + (BinauthzManagementServiceV1Client, "grpc"), + (BinauthzManagementServiceV1AsyncClient, "grpc_asyncio"), + ], ) -def test_binauthz_management_service_v1_client_from_service_account_info(client_class): +def test_binauthz_management_service_v1_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") @pytest.mark.parametrize( @@ -141,24 +152,33 @@ def test_binauthz_management_service_v1_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", - [BinauthzManagementServiceV1Client, BinauthzManagementServiceV1AsyncClient,], + "client_class,transport_name", + [ + (BinauthzManagementServiceV1Client, "grpc"), + (BinauthzManagementServiceV1AsyncClient, "grpc_asyncio"), + ], ) -def test_binauthz_management_service_v1_client_from_service_account_file(client_class): +def test_binauthz_management_service_v1_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") def test_binauthz_management_service_v1_client_get_transport_class(): @@ -531,7 +551,9 @@ def test_binauthz_management_service_v1_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) @@ -671,10 +693,17 @@ def test_binauthz_management_service_v1_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [service.GetPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.GetPolicyRequest, + dict, + ], +) def test_get_policy(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -710,7 +739,8 @@ def test_get_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -726,7 +756,8 @@ async def test_get_policy_async( transport: str = "grpc_asyncio", request_type=service.GetPolicyRequest ): client = BinauthzManagementServiceV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -774,7 +805,7 @@ def test_get_policy_field_headers(): # a field header. Set these to a non-empty value. request = service.GetPolicyRequest() - 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_policy), "__call__") as call: @@ -788,7 +819,10 @@ def test_get_policy_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 @@ -801,7 +835,7 @@ async def test_get_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetPolicyRequest() - 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_policy), "__call__") as call: @@ -815,7 +849,10 @@ async def test_get_policy_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_policy_flattened(): @@ -829,7 +866,9 @@ def test_get_policy_flattened(): call.return_value = resources.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_policy(name="name_value",) + client.get_policy( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -849,7 +888,8 @@ def test_get_policy_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_policy( - service.GetPolicyRequest(), name="name_value", + service.GetPolicyRequest(), + name="name_value", ) @@ -867,7 +907,9 @@ async def test_get_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_policy(name="name_value",) + response = await client.get_policy( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -888,14 +930,22 @@ async def test_get_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_policy( - service.GetPolicyRequest(), name="name_value", + service.GetPolicyRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [service.UpdatePolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.UpdatePolicyRequest, + dict, + ], +) def test_update_policy(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -931,7 +981,8 @@ def test_update_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -947,7 +998,8 @@ async def test_update_policy_async( transport: str = "grpc_asyncio", request_type=service.UpdatePolicyRequest ): client = BinauthzManagementServiceV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -995,7 +1047,7 @@ def test_update_policy_field_headers(): # a field header. Set these to a non-empty value. request = service.UpdatePolicyRequest() - request.policy.name = "policy.name/value" + request.policy.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_policy), "__call__") as call: @@ -1009,7 +1061,10 @@ def test_update_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "policy.name=policy.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "policy.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1022,7 +1077,7 @@ async def test_update_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = service.UpdatePolicyRequest() - request.policy.name = "policy.name/value" + request.policy.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_policy), "__call__") as call: @@ -1036,7 +1091,10 @@ async def test_update_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "policy.name=policy.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "policy.name=name_value", + ) in kw["metadata"] def test_update_policy_flattened(): @@ -1050,7 +1108,9 @@ def test_update_policy_flattened(): call.return_value = resources.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_policy(policy=resources.Policy(name="name_value"),) + client.update_policy( + policy=resources.Policy(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1070,7 +1130,8 @@ def test_update_policy_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.update_policy( - service.UpdatePolicyRequest(), policy=resources.Policy(name="name_value"), + service.UpdatePolicyRequest(), + policy=resources.Policy(name="name_value"), ) @@ -1111,14 +1172,22 @@ async def test_update_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.update_policy( - service.UpdatePolicyRequest(), policy=resources.Policy(name="name_value"), + service.UpdatePolicyRequest(), + policy=resources.Policy(name="name_value"), ) -@pytest.mark.parametrize("request_type", [service.CreateAttestorRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.CreateAttestorRequest, + dict, + ], +) def test_create_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1152,7 +1221,8 @@ def test_create_attestor_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 = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1168,7 +1238,8 @@ async def test_create_attestor_async( transport: str = "grpc_asyncio", request_type=service.CreateAttestorRequest ): client = BinauthzManagementServiceV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1179,7 +1250,10 @@ async def test_create_attestor_async( with mock.patch.object(type(client.transport.create_attestor), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Attestor(name="name_value", description="description_value",) + resources.Attestor( + name="name_value", + description="description_value", + ) ) response = await client.create_attestor(request) @@ -1208,7 +1282,7 @@ def test_create_attestor_field_headers(): # a field header. Set these to a non-empty value. request = service.CreateAttestorRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_attestor), "__call__") as call: @@ -1222,7 +1296,10 @@ def test_create_attestor_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 @@ -1235,7 +1312,7 @@ async def test_create_attestor_field_headers_async(): # a field header. Set these to a non-empty value. request = service.CreateAttestorRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_attestor), "__call__") as call: @@ -1249,7 +1326,10 @@ async def test_create_attestor_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_attestor_flattened(): @@ -1352,10 +1432,17 @@ async def test_create_attestor_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [service.GetAttestorRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.GetAttestorRequest, + dict, + ], +) def test_get_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1389,7 +1476,8 @@ def test_get_attestor_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 = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1405,7 +1493,8 @@ async def test_get_attestor_async( transport: str = "grpc_asyncio", request_type=service.GetAttestorRequest ): client = BinauthzManagementServiceV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1416,7 +1505,10 @@ async def test_get_attestor_async( with mock.patch.object(type(client.transport.get_attestor), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Attestor(name="name_value", description="description_value",) + resources.Attestor( + name="name_value", + description="description_value", + ) ) response = await client.get_attestor(request) @@ -1445,7 +1537,7 @@ def test_get_attestor_field_headers(): # a field header. Set these to a non-empty value. request = service.GetAttestorRequest() - 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_attestor), "__call__") as call: @@ -1459,7 +1551,10 @@ def test_get_attestor_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 @@ -1472,7 +1567,7 @@ async def test_get_attestor_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetAttestorRequest() - 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_attestor), "__call__") as call: @@ -1486,7 +1581,10 @@ async def test_get_attestor_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_attestor_flattened(): @@ -1500,7 +1598,9 @@ def test_get_attestor_flattened(): call.return_value = resources.Attestor() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_attestor(name="name_value",) + client.get_attestor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1520,7 +1620,8 @@ def test_get_attestor_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_attestor( - service.GetAttestorRequest(), name="name_value", + service.GetAttestorRequest(), + name="name_value", ) @@ -1538,7 +1639,9 @@ async def test_get_attestor_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Attestor()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_attestor(name="name_value",) + response = await client.get_attestor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1559,14 +1662,22 @@ async def test_get_attestor_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_attestor( - service.GetAttestorRequest(), name="name_value", + service.GetAttestorRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [service.UpdateAttestorRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.UpdateAttestorRequest, + dict, + ], +) def test_update_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1600,7 +1711,8 @@ def test_update_attestor_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 = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1616,7 +1728,8 @@ async def test_update_attestor_async( transport: str = "grpc_asyncio", request_type=service.UpdateAttestorRequest ): client = BinauthzManagementServiceV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1627,7 +1740,10 @@ async def test_update_attestor_async( with mock.patch.object(type(client.transport.update_attestor), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Attestor(name="name_value", description="description_value",) + resources.Attestor( + name="name_value", + description="description_value", + ) ) response = await client.update_attestor(request) @@ -1656,7 +1772,7 @@ def test_update_attestor_field_headers(): # a field header. Set these to a non-empty value. request = service.UpdateAttestorRequest() - request.attestor.name = "attestor.name/value" + request.attestor.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_attestor), "__call__") as call: @@ -1670,9 +1786,10 @@ def test_update_attestor_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "attestor.name=attestor.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "attestor.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1685,7 +1802,7 @@ async def test_update_attestor_field_headers_async(): # a field header. Set these to a non-empty value. request = service.UpdateAttestorRequest() - request.attestor.name = "attestor.name/value" + request.attestor.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_attestor), "__call__") as call: @@ -1699,9 +1816,10 @@ async def test_update_attestor_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "attestor.name=attestor.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "attestor.name=name_value", + ) in kw["metadata"] def test_update_attestor_flattened(): @@ -1715,7 +1833,9 @@ def test_update_attestor_flattened(): call.return_value = resources.Attestor() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_attestor(attestor=resources.Attestor(name="name_value"),) + client.update_attestor( + attestor=resources.Attestor(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1782,10 +1902,17 @@ async def test_update_attestor_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [service.ListAttestorsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.ListAttestorsRequest, + dict, + ], +) def test_list_attestors(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1814,7 +1941,8 @@ def test_list_attestors_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 = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1830,7 +1958,8 @@ async def test_list_attestors_async( transport: str = "grpc_asyncio", request_type=service.ListAttestorsRequest ): client = BinauthzManagementServiceV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1841,7 +1970,9 @@ async def test_list_attestors_async( with mock.patch.object(type(client.transport.list_attestors), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.ListAttestorsResponse(next_page_token="next_page_token_value",) + service.ListAttestorsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_attestors(request) @@ -1869,7 +2000,7 @@ def test_list_attestors_field_headers(): # a field header. Set these to a non-empty value. request = service.ListAttestorsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_attestors), "__call__") as call: @@ -1883,7 +2014,10 @@ def test_list_attestors_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 @@ -1896,7 +2030,7 @@ async def test_list_attestors_field_headers_async(): # a field header. Set these to a non-empty value. request = service.ListAttestorsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_attestors), "__call__") as call: @@ -1912,7 +2046,10 @@ async def test_list_attestors_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_attestors_flattened(): @@ -1926,7 +2063,9 @@ def test_list_attestors_flattened(): call.return_value = service.ListAttestorsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_attestors(parent="parent_value",) + client.list_attestors( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1946,7 +2085,8 @@ def test_list_attestors_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.list_attestors( - service.ListAttestorsRequest(), parent="parent_value", + service.ListAttestorsRequest(), + parent="parent_value", ) @@ -1966,7 +2106,9 @@ async def test_list_attestors_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_attestors(parent="parent_value",) + response = await client.list_attestors( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1987,13 +2129,15 @@ async def test_list_attestors_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_attestors( - service.ListAttestorsRequest(), parent="parent_value", + service.ListAttestorsRequest(), + parent="parent_value", ) def test_list_attestors_pager(transport_name: str = "grpc"): client = BinauthzManagementServiceV1Client( - 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. @@ -2008,12 +2152,21 @@ def test_list_attestors_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - service.ListAttestorsResponse(attestors=[], next_page_token="def",), service.ListAttestorsResponse( - attestors=[resources.Attestor(),], next_page_token="ghi", + attestors=[], + next_page_token="def", ), service.ListAttestorsResponse( - attestors=[resources.Attestor(), resources.Attestor(),], + attestors=[ + resources.Attestor(), + ], + next_page_token="ghi", + ), + service.ListAttestorsResponse( + attestors=[ + resources.Attestor(), + resources.Attestor(), + ], ), RuntimeError, ) @@ -2026,14 +2179,15 @@ def test_list_attestors_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, resources.Attestor) for i in results) def test_list_attestors_pages(transport_name: str = "grpc"): client = BinauthzManagementServiceV1Client( - 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. @@ -2048,12 +2202,21 @@ def test_list_attestors_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - service.ListAttestorsResponse(attestors=[], next_page_token="def",), service.ListAttestorsResponse( - attestors=[resources.Attestor(),], next_page_token="ghi", + attestors=[], + next_page_token="def", ), service.ListAttestorsResponse( - attestors=[resources.Attestor(), resources.Attestor(),], + attestors=[ + resources.Attestor(), + ], + next_page_token="ghi", + ), + service.ListAttestorsResponse( + attestors=[ + resources.Attestor(), + resources.Attestor(), + ], ), RuntimeError, ) @@ -2082,19 +2245,30 @@ async def test_list_attestors_async_pager(): ], next_page_token="abc", ), - service.ListAttestorsResponse(attestors=[], next_page_token="def",), service.ListAttestorsResponse( - attestors=[resources.Attestor(),], next_page_token="ghi", + attestors=[], + next_page_token="def", ), service.ListAttestorsResponse( - attestors=[resources.Attestor(), resources.Attestor(),], + attestors=[ + resources.Attestor(), + ], + next_page_token="ghi", + ), + service.ListAttestorsResponse( + attestors=[ + resources.Attestor(), + resources.Attestor(), + ], ), RuntimeError, ) - async_pager = await client.list_attestors(request={},) + async_pager = await client.list_attestors( + 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 @@ -2121,26 +2295,44 @@ async def test_list_attestors_async_pages(): ], next_page_token="abc", ), - service.ListAttestorsResponse(attestors=[], next_page_token="def",), service.ListAttestorsResponse( - attestors=[resources.Attestor(),], next_page_token="ghi", + attestors=[], + next_page_token="def", ), service.ListAttestorsResponse( - attestors=[resources.Attestor(), resources.Attestor(),], + attestors=[ + resources.Attestor(), + ], + next_page_token="ghi", + ), + service.ListAttestorsResponse( + attestors=[ + resources.Attestor(), + resources.Attestor(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_attestors(request={})).pages: + async for page_ in ( + await client.list_attestors(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", [service.DeleteAttestorRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.DeleteAttestorRequest, + dict, + ], +) def test_delete_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2166,7 +2358,8 @@ def test_delete_attestor_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 = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2182,7 +2375,8 @@ async def test_delete_attestor_async( transport: str = "grpc_asyncio", request_type=service.DeleteAttestorRequest ): client = BinauthzManagementServiceV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2218,7 +2412,7 @@ def test_delete_attestor_field_headers(): # a field header. Set these to a non-empty value. request = service.DeleteAttestorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_attestor), "__call__") as call: @@ -2232,7 +2426,10 @@ def test_delete_attestor_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 @@ -2245,7 +2442,7 @@ async def test_delete_attestor_field_headers_async(): # a field header. Set these to a non-empty value. request = service.DeleteAttestorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_attestor), "__call__") as call: @@ -2259,7 +2456,10 @@ async def test_delete_attestor_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_attestor_flattened(): @@ -2273,7 +2473,9 @@ def test_delete_attestor_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_attestor(name="name_value",) + client.delete_attestor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2293,7 +2495,8 @@ def test_delete_attestor_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.delete_attestor( - service.DeleteAttestorRequest(), name="name_value", + service.DeleteAttestorRequest(), + name="name_value", ) @@ -2311,7 +2514,9 @@ async def test_delete_attestor_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_attestor(name="name_value",) + response = await client.delete_attestor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2332,7 +2537,8 @@ async def test_delete_attestor_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_attestor( - service.DeleteAttestorRequest(), name="name_value", + service.DeleteAttestorRequest(), + name="name_value", ) @@ -2343,7 +2549,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = BinauthzManagementServiceV1Client( - 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. @@ -2364,7 +2571,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = BinauthzManagementServiceV1Client( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -2381,7 +2589,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = BinauthzManagementServiceV1Client( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2424,13 +2633,27 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = BinauthzManagementServiceV1Client.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 = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.BinauthzManagementServiceV1GrpcTransport, + client.transport, + transports.BinauthzManagementServiceV1GrpcTransport, ) @@ -2471,6 +2694,14 @@ def test_binauthz_management_service_v1_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_binauthz_management_service_v1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -2482,7 +2713,8 @@ def test_binauthz_management_service_v1_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.BinauthzManagementServiceV1Transport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2622,24 +2854,40 @@ def test_binauthz_management_service_v1_grpc_transport_client_cert_source_for_mt ) -def test_binauthz_management_service_v1_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_binauthz_management_service_v1_host_no_port(transport_name): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") -def test_binauthz_management_service_v1_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_binauthz_management_service_v1_host_with_port(transport_name): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:8000" + assert client.transport._host == ("binaryauthorization.googleapis.com:8000") def test_binauthz_management_service_v1_grpc_transport_channel(): @@ -2647,7 +2895,8 @@ def test_binauthz_management_service_v1_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.BinauthzManagementServiceV1GrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2659,7 +2908,8 @@ def test_binauthz_management_service_v1_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.BinauthzManagementServiceV1GrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2772,7 +3022,8 @@ def test_attestor_path(): project = "squid" attestor = "clam" expected = "projects/{project}/attestors/{attestor}".format( - project=project, attestor=attestor, + project=project, + attestor=attestor, ) actual = BinauthzManagementServiceV1Client.attestor_path(project, attestor) assert expected == actual @@ -2792,7 +3043,9 @@ def test_parse_attestor_path(): def test_policy_path(): project = "oyster" - expected = "projects/{project}/policy".format(project=project,) + expected = "projects/{project}/policy".format( + project=project, + ) actual = BinauthzManagementServiceV1Client.policy_path(project) assert expected == actual @@ -2832,7 +3085,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = BinauthzManagementServiceV1Client.common_folder_path(folder) assert expected == actual @@ -2850,7 +3105,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = BinauthzManagementServiceV1Client.common_organization_path(organization) assert expected == actual @@ -2868,7 +3125,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = BinauthzManagementServiceV1Client.common_project_path(project) assert expected == actual @@ -2888,7 +3147,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = BinauthzManagementServiceV1Client.common_location_path(project, location) assert expected == actual @@ -2913,7 +3173,8 @@ def test_client_with_default_client_info(): transports.BinauthzManagementServiceV1Transport, "_prep_wrapped_messages" ) as prep: client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2922,7 +3183,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = BinauthzManagementServiceV1Client.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) @@ -2930,7 +3192,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = BinauthzManagementServiceV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py b/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py index dbfcc96..955572d 100644 --- a/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py +++ b/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -90,20 +96,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [SystemPolicyV1Client, SystemPolicyV1AsyncClient,] + "client_class,transport_name", + [ + (SystemPolicyV1Client, "grpc"), + (SystemPolicyV1AsyncClient, "grpc_asyncio"), + ], ) -def test_system_policy_v1_client_from_service_account_info(client_class): +def test_system_policy_v1_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") @pytest.mark.parametrize( @@ -132,23 +144,33 @@ def test_system_policy_v1_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [SystemPolicyV1Client, SystemPolicyV1AsyncClient,] + "client_class,transport_name", + [ + (SystemPolicyV1Client, "grpc"), + (SystemPolicyV1AsyncClient, "grpc_asyncio"), + ], ) -def test_system_policy_v1_client_from_service_account_file(client_class): +def test_system_policy_v1_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") def test_system_policy_v1_client_get_transport_class(): @@ -496,7 +518,9 @@ def test_system_policy_v1_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) @@ -636,10 +660,17 @@ def test_system_policy_v1_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [service.GetSystemPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.GetSystemPolicyRequest, + dict, + ], +) def test_get_system_policy(request_type, transport: str = "grpc"): client = SystemPolicyV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -677,7 +708,8 @@ def test_get_system_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SystemPolicyV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -695,7 +727,8 @@ async def test_get_system_policy_async( transport: str = "grpc_asyncio", request_type=service.GetSystemPolicyRequest ): client = SystemPolicyV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -737,13 +770,15 @@ async def test_get_system_policy_async_from_dict(): def test_get_system_policy_field_headers(): - client = SystemPolicyV1Client(credentials=ga_credentials.AnonymousCredentials(),) + client = SystemPolicyV1Client( + 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 = service.GetSystemPolicyRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -759,7 +794,10 @@ def test_get_system_policy_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 @@ -772,7 +810,7 @@ async def test_get_system_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetSystemPolicyRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -788,11 +826,16 @@ async def test_get_system_policy_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_system_policy_flattened(): - client = SystemPolicyV1Client(credentials=ga_credentials.AnonymousCredentials(),) + client = SystemPolicyV1Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -802,7 +845,9 @@ def test_get_system_policy_flattened(): call.return_value = resources.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_system_policy(name="name_value",) + client.get_system_policy( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -814,13 +859,16 @@ def test_get_system_policy_flattened(): def test_get_system_policy_flattened_error(): - client = SystemPolicyV1Client(credentials=ga_credentials.AnonymousCredentials(),) + client = SystemPolicyV1Client( + 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_system_policy( - service.GetSystemPolicyRequest(), name="name_value", + service.GetSystemPolicyRequest(), + name="name_value", ) @@ -840,7 +888,9 @@ async def test_get_system_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_system_policy(name="name_value",) + response = await client.get_system_policy( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -861,7 +911,8 @@ async def test_get_system_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_system_policy( - service.GetSystemPolicyRequest(), name="name_value", + service.GetSystemPolicyRequest(), + name="name_value", ) @@ -872,7 +923,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SystemPolicyV1Client( - 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. @@ -892,7 +944,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = SystemPolicyV1Client(client_options=options, transport=transport,) + client = SystemPolicyV1Client( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -908,7 +963,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SystemPolicyV1Client( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -951,10 +1007,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = SystemPolicyV1Client.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 = SystemPolicyV1Client(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.SystemPolicyV1GrpcTransport,) + client = SystemPolicyV1Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.SystemPolicyV1GrpcTransport, + ) def test_system_policy_v1_base_transport_error(): @@ -986,6 +1060,14 @@ def test_system_policy_v1_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_system_policy_v1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -997,7 +1079,8 @@ def test_system_policy_v1_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SystemPolicyV1Transport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1130,24 +1213,40 @@ def test_system_policy_v1_grpc_transport_client_cert_source_for_mtls(transport_c ) -def test_system_policy_v1_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_system_policy_v1_host_no_port(transport_name): client = SystemPolicyV1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") -def test_system_policy_v1_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_system_policy_v1_host_with_port(transport_name): client = SystemPolicyV1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:8000" + assert client.transport._host == ("binaryauthorization.googleapis.com:8000") def test_system_policy_v1_grpc_transport_channel(): @@ -1155,7 +1254,8 @@ def test_system_policy_v1_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.SystemPolicyV1GrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1167,7 +1267,8 @@ def test_system_policy_v1_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.SystemPolicyV1GrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1276,7 +1377,9 @@ def test_system_policy_v1_transport_channel_mtls_with_adc(transport_class): def test_policy_path(): project = "squid" - expected = "projects/{project}/policy".format(project=project,) + expected = "projects/{project}/policy".format( + project=project, + ) actual = SystemPolicyV1Client.policy_path(project) assert expected == actual @@ -1314,7 +1417,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = SystemPolicyV1Client.common_folder_path(folder) assert expected == actual @@ -1332,7 +1437,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = SystemPolicyV1Client.common_organization_path(organization) assert expected == actual @@ -1350,7 +1457,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = SystemPolicyV1Client.common_project_path(project) assert expected == actual @@ -1370,7 +1479,8 @@ def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = SystemPolicyV1Client.common_location_path(project, location) assert expected == actual @@ -1395,7 +1505,8 @@ def test_client_with_default_client_info(): transports.SystemPolicyV1Transport, "_prep_wrapped_messages" ) as prep: client = SystemPolicyV1Client( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1404,7 +1515,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = SystemPolicyV1Client.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) @@ -1412,7 +1524,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = SystemPolicyV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py b/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py index 4370b69..8f32fe8 100644 --- a/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py +++ b/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -91,20 +97,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [ValidationHelperV1Client, ValidationHelperV1AsyncClient,] + "client_class,transport_name", + [ + (ValidationHelperV1Client, "grpc"), + (ValidationHelperV1AsyncClient, "grpc_asyncio"), + ], ) -def test_validation_helper_v1_client_from_service_account_info(client_class): +def test_validation_helper_v1_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") @pytest.mark.parametrize( @@ -133,23 +145,33 @@ def test_validation_helper_v1_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [ValidationHelperV1Client, ValidationHelperV1AsyncClient,] + "client_class,transport_name", + [ + (ValidationHelperV1Client, "grpc"), + (ValidationHelperV1AsyncClient, "grpc_asyncio"), + ], ) -def test_validation_helper_v1_client_from_service_account_file(client_class): +def test_validation_helper_v1_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") def test_validation_helper_v1_client_get_transport_class(): @@ -507,7 +529,9 @@ def test_validation_helper_v1_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) @@ -648,11 +672,16 @@ def test_validation_helper_v1_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [service.ValidateAttestationOccurrenceRequest, dict,] + "request_type", + [ + service.ValidateAttestationOccurrenceRequest, + dict, + ], ) def test_validate_attestation_occurrence(request_type, transport: str = "grpc"): client = ValidationHelperV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -687,7 +716,8 @@ def test_validate_attestation_occurrence_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 = ValidationHelperV1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -706,7 +736,8 @@ async def test_validate_attestation_occurrence_async( request_type=service.ValidateAttestationOccurrenceRequest, ): client = ValidationHelperV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -753,7 +784,7 @@ def test_validate_attestation_occurrence_field_headers(): # a field header. Set these to a non-empty value. request = service.ValidateAttestationOccurrenceRequest() - request.attestor = "attestor/value" + request.attestor = "attestor_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -769,7 +800,10 @@ def test_validate_attestation_occurrence_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "attestor=attestor/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "attestor=attestor_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -782,7 +816,7 @@ async def test_validate_attestation_occurrence_field_headers_async(): # a field header. Set these to a non-empty value. request = service.ValidateAttestationOccurrenceRequest() - request.attestor = "attestor/value" + request.attestor = "attestor_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -800,7 +834,10 @@ async def test_validate_attestation_occurrence_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "attestor=attestor/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "attestor=attestor_value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -810,7 +847,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = ValidationHelperV1Client( - 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. @@ -830,7 +868,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = ValidationHelperV1Client(client_options=options, transport=transport,) + client = ValidationHelperV1Client( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -846,7 +887,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = ValidationHelperV1Client( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -889,12 +931,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = ValidationHelperV1Client.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 = ValidationHelperV1Client( credentials=ga_credentials.AnonymousCredentials(), ) - assert isinstance(client.transport, transports.ValidationHelperV1GrpcTransport,) + assert isinstance( + client.transport, + transports.ValidationHelperV1GrpcTransport, + ) def test_validation_helper_v1_base_transport_error(): @@ -926,6 +984,14 @@ def test_validation_helper_v1_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_validation_helper_v1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -937,7 +1003,8 @@ def test_validation_helper_v1_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ValidationHelperV1Transport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1072,24 +1139,40 @@ def test_validation_helper_v1_grpc_transport_client_cert_source_for_mtls( ) -def test_validation_helper_v1_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_validation_helper_v1_host_no_port(transport_name): client = ValidationHelperV1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") -def test_validation_helper_v1_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_validation_helper_v1_host_with_port(transport_name): client = ValidationHelperV1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:8000" + assert client.transport._host == ("binaryauthorization.googleapis.com:8000") def test_validation_helper_v1_grpc_transport_channel(): @@ -1097,7 +1180,8 @@ def test_validation_helper_v1_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.ValidationHelperV1GrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1109,7 +1193,8 @@ def test_validation_helper_v1_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.ValidationHelperV1GrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1238,7 +1323,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = ValidationHelperV1Client.common_folder_path(folder) assert expected == actual @@ -1256,7 +1343,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = ValidationHelperV1Client.common_organization_path(organization) assert expected == actual @@ -1274,7 +1363,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = ValidationHelperV1Client.common_project_path(project) assert expected == actual @@ -1294,7 +1385,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = ValidationHelperV1Client.common_location_path(project, location) assert expected == actual @@ -1319,7 +1411,8 @@ def test_client_with_default_client_info(): transports.ValidationHelperV1Transport, "_prep_wrapped_messages" ) as prep: client = ValidationHelperV1Client( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1328,7 +1421,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = ValidationHelperV1Client.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) @@ -1336,7 +1430,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = ValidationHelperV1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py b/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py index c826ae7..03c9c03 100644 --- a/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py +++ b/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -104,14 +110,14 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - BinauthzManagementServiceV1Beta1Client, - BinauthzManagementServiceV1Beta1AsyncClient, + (BinauthzManagementServiceV1Beta1Client, "grpc"), + (BinauthzManagementServiceV1Beta1AsyncClient, "grpc_asyncio"), ], ) def test_binauthz_management_service_v1_beta1_client_from_service_account_info( - client_class, + client_class, transport_name ): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -119,11 +125,11 @@ def test_binauthz_management_service_v1_beta1_client_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") @pytest.mark.parametrize( @@ -155,29 +161,33 @@ def test_binauthz_management_service_v1_beta1_client_service_account_always_use_ @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - BinauthzManagementServiceV1Beta1Client, - BinauthzManagementServiceV1Beta1AsyncClient, + (BinauthzManagementServiceV1Beta1Client, "grpc"), + (BinauthzManagementServiceV1Beta1AsyncClient, "grpc_asyncio"), ], ) def test_binauthz_management_service_v1_beta1_client_from_service_account_file( - client_class, + 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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") def test_binauthz_management_service_v1_beta1_client_get_transport_class(): @@ -553,7 +563,9 @@ def test_binauthz_management_service_v1_beta1_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) @@ -693,10 +705,17 @@ def test_binauthz_management_service_v1_beta1_client_create_channel_credentials_ ) -@pytest.mark.parametrize("request_type", [service.GetPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.GetPolicyRequest, + dict, + ], +) def test_get_policy(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -732,7 +751,8 @@ def test_get_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -748,7 +768,8 @@ async def test_get_policy_async( transport: str = "grpc_asyncio", request_type=service.GetPolicyRequest ): client = BinauthzManagementServiceV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -796,7 +817,7 @@ def test_get_policy_field_headers(): # a field header. Set these to a non-empty value. request = service.GetPolicyRequest() - 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_policy), "__call__") as call: @@ -810,7 +831,10 @@ def test_get_policy_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 @@ -823,7 +847,7 @@ async def test_get_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetPolicyRequest() - 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_policy), "__call__") as call: @@ -837,7 +861,10 @@ async def test_get_policy_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_policy_flattened(): @@ -851,7 +878,9 @@ def test_get_policy_flattened(): call.return_value = resources.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_policy(name="name_value",) + client.get_policy( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -871,7 +900,8 @@ def test_get_policy_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_policy( - service.GetPolicyRequest(), name="name_value", + service.GetPolicyRequest(), + name="name_value", ) @@ -889,7 +919,9 @@ async def test_get_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_policy(name="name_value",) + response = await client.get_policy( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -910,14 +942,22 @@ async def test_get_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_policy( - service.GetPolicyRequest(), name="name_value", + service.GetPolicyRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [service.UpdatePolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.UpdatePolicyRequest, + dict, + ], +) def test_update_policy(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -953,7 +993,8 @@ def test_update_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -969,7 +1010,8 @@ async def test_update_policy_async( transport: str = "grpc_asyncio", request_type=service.UpdatePolicyRequest ): client = BinauthzManagementServiceV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1017,7 +1059,7 @@ def test_update_policy_field_headers(): # a field header. Set these to a non-empty value. request = service.UpdatePolicyRequest() - request.policy.name = "policy.name/value" + request.policy.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_policy), "__call__") as call: @@ -1031,7 +1073,10 @@ def test_update_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "policy.name=policy.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "policy.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1044,7 +1089,7 @@ async def test_update_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = service.UpdatePolicyRequest() - request.policy.name = "policy.name/value" + request.policy.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_policy), "__call__") as call: @@ -1058,7 +1103,10 @@ async def test_update_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "policy.name=policy.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "policy.name=name_value", + ) in kw["metadata"] def test_update_policy_flattened(): @@ -1072,7 +1120,9 @@ def test_update_policy_flattened(): call.return_value = resources.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_policy(policy=resources.Policy(name="name_value"),) + client.update_policy( + policy=resources.Policy(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1092,7 +1142,8 @@ def test_update_policy_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.update_policy( - service.UpdatePolicyRequest(), policy=resources.Policy(name="name_value"), + service.UpdatePolicyRequest(), + policy=resources.Policy(name="name_value"), ) @@ -1133,14 +1184,22 @@ async def test_update_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.update_policy( - service.UpdatePolicyRequest(), policy=resources.Policy(name="name_value"), + service.UpdatePolicyRequest(), + policy=resources.Policy(name="name_value"), ) -@pytest.mark.parametrize("request_type", [service.CreateAttestorRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.CreateAttestorRequest, + dict, + ], +) def test_create_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1174,7 +1233,8 @@ def test_create_attestor_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 = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1190,7 +1250,8 @@ async def test_create_attestor_async( transport: str = "grpc_asyncio", request_type=service.CreateAttestorRequest ): client = BinauthzManagementServiceV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1201,7 +1262,10 @@ async def test_create_attestor_async( with mock.patch.object(type(client.transport.create_attestor), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Attestor(name="name_value", description="description_value",) + resources.Attestor( + name="name_value", + description="description_value", + ) ) response = await client.create_attestor(request) @@ -1230,7 +1294,7 @@ def test_create_attestor_field_headers(): # a field header. Set these to a non-empty value. request = service.CreateAttestorRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_attestor), "__call__") as call: @@ -1244,7 +1308,10 @@ def test_create_attestor_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 @@ -1257,7 +1324,7 @@ async def test_create_attestor_field_headers_async(): # a field header. Set these to a non-empty value. request = service.CreateAttestorRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_attestor), "__call__") as call: @@ -1271,7 +1338,10 @@ async def test_create_attestor_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_attestor_flattened(): @@ -1374,10 +1444,17 @@ async def test_create_attestor_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [service.GetAttestorRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.GetAttestorRequest, + dict, + ], +) def test_get_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1411,7 +1488,8 @@ def test_get_attestor_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 = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1427,7 +1505,8 @@ async def test_get_attestor_async( transport: str = "grpc_asyncio", request_type=service.GetAttestorRequest ): client = BinauthzManagementServiceV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1438,7 +1517,10 @@ async def test_get_attestor_async( with mock.patch.object(type(client.transport.get_attestor), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Attestor(name="name_value", description="description_value",) + resources.Attestor( + name="name_value", + description="description_value", + ) ) response = await client.get_attestor(request) @@ -1467,7 +1549,7 @@ def test_get_attestor_field_headers(): # a field header. Set these to a non-empty value. request = service.GetAttestorRequest() - 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_attestor), "__call__") as call: @@ -1481,7 +1563,10 @@ def test_get_attestor_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 @@ -1494,7 +1579,7 @@ async def test_get_attestor_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetAttestorRequest() - 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_attestor), "__call__") as call: @@ -1508,7 +1593,10 @@ async def test_get_attestor_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_attestor_flattened(): @@ -1522,7 +1610,9 @@ def test_get_attestor_flattened(): call.return_value = resources.Attestor() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_attestor(name="name_value",) + client.get_attestor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1542,7 +1632,8 @@ def test_get_attestor_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_attestor( - service.GetAttestorRequest(), name="name_value", + service.GetAttestorRequest(), + name="name_value", ) @@ -1560,7 +1651,9 @@ async def test_get_attestor_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Attestor()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_attestor(name="name_value",) + response = await client.get_attestor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1581,14 +1674,22 @@ async def test_get_attestor_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_attestor( - service.GetAttestorRequest(), name="name_value", + service.GetAttestorRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [service.UpdateAttestorRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.UpdateAttestorRequest, + dict, + ], +) def test_update_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1622,7 +1723,8 @@ def test_update_attestor_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 = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1638,7 +1740,8 @@ async def test_update_attestor_async( transport: str = "grpc_asyncio", request_type=service.UpdateAttestorRequest ): client = BinauthzManagementServiceV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1649,7 +1752,10 @@ async def test_update_attestor_async( with mock.patch.object(type(client.transport.update_attestor), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.Attestor(name="name_value", description="description_value",) + resources.Attestor( + name="name_value", + description="description_value", + ) ) response = await client.update_attestor(request) @@ -1678,7 +1784,7 @@ def test_update_attestor_field_headers(): # a field header. Set these to a non-empty value. request = service.UpdateAttestorRequest() - request.attestor.name = "attestor.name/value" + request.attestor.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_attestor), "__call__") as call: @@ -1692,9 +1798,10 @@ def test_update_attestor_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "attestor.name=attestor.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "attestor.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1707,7 +1814,7 @@ async def test_update_attestor_field_headers_async(): # a field header. Set these to a non-empty value. request = service.UpdateAttestorRequest() - request.attestor.name = "attestor.name/value" + request.attestor.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_attestor), "__call__") as call: @@ -1721,9 +1828,10 @@ async def test_update_attestor_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "attestor.name=attestor.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "attestor.name=name_value", + ) in kw["metadata"] def test_update_attestor_flattened(): @@ -1737,7 +1845,9 @@ def test_update_attestor_flattened(): call.return_value = resources.Attestor() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_attestor(attestor=resources.Attestor(name="name_value"),) + client.update_attestor( + attestor=resources.Attestor(name="name_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -1804,10 +1914,17 @@ async def test_update_attestor_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [service.ListAttestorsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.ListAttestorsRequest, + dict, + ], +) def test_list_attestors(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1836,7 +1953,8 @@ def test_list_attestors_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 = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1852,7 +1970,8 @@ async def test_list_attestors_async( transport: str = "grpc_asyncio", request_type=service.ListAttestorsRequest ): client = BinauthzManagementServiceV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1863,7 +1982,9 @@ async def test_list_attestors_async( with mock.patch.object(type(client.transport.list_attestors), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.ListAttestorsResponse(next_page_token="next_page_token_value",) + service.ListAttestorsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_attestors(request) @@ -1891,7 +2012,7 @@ def test_list_attestors_field_headers(): # a field header. Set these to a non-empty value. request = service.ListAttestorsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_attestors), "__call__") as call: @@ -1905,7 +2026,10 @@ def test_list_attestors_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 @@ -1918,7 +2042,7 @@ async def test_list_attestors_field_headers_async(): # a field header. Set these to a non-empty value. request = service.ListAttestorsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_attestors), "__call__") as call: @@ -1934,7 +2058,10 @@ async def test_list_attestors_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_attestors_flattened(): @@ -1948,7 +2075,9 @@ def test_list_attestors_flattened(): call.return_value = service.ListAttestorsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_attestors(parent="parent_value",) + client.list_attestors( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1968,7 +2097,8 @@ def test_list_attestors_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.list_attestors( - service.ListAttestorsRequest(), parent="parent_value", + service.ListAttestorsRequest(), + parent="parent_value", ) @@ -1988,7 +2118,9 @@ async def test_list_attestors_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_attestors(parent="parent_value",) + response = await client.list_attestors( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2009,13 +2141,15 @@ async def test_list_attestors_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_attestors( - service.ListAttestorsRequest(), parent="parent_value", + service.ListAttestorsRequest(), + parent="parent_value", ) def test_list_attestors_pager(transport_name: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - 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. @@ -2030,12 +2164,21 @@ def test_list_attestors_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - service.ListAttestorsResponse(attestors=[], next_page_token="def",), service.ListAttestorsResponse( - attestors=[resources.Attestor(),], next_page_token="ghi", + attestors=[], + next_page_token="def", ), service.ListAttestorsResponse( - attestors=[resources.Attestor(), resources.Attestor(),], + attestors=[ + resources.Attestor(), + ], + next_page_token="ghi", + ), + service.ListAttestorsResponse( + attestors=[ + resources.Attestor(), + resources.Attestor(), + ], ), RuntimeError, ) @@ -2048,14 +2191,15 @@ def test_list_attestors_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, resources.Attestor) for i in results) def test_list_attestors_pages(transport_name: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - 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. @@ -2070,12 +2214,21 @@ def test_list_attestors_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - service.ListAttestorsResponse(attestors=[], next_page_token="def",), service.ListAttestorsResponse( - attestors=[resources.Attestor(),], next_page_token="ghi", + attestors=[], + next_page_token="def", ), service.ListAttestorsResponse( - attestors=[resources.Attestor(), resources.Attestor(),], + attestors=[ + resources.Attestor(), + ], + next_page_token="ghi", + ), + service.ListAttestorsResponse( + attestors=[ + resources.Attestor(), + resources.Attestor(), + ], ), RuntimeError, ) @@ -2104,19 +2257,30 @@ async def test_list_attestors_async_pager(): ], next_page_token="abc", ), - service.ListAttestorsResponse(attestors=[], next_page_token="def",), service.ListAttestorsResponse( - attestors=[resources.Attestor(),], next_page_token="ghi", + attestors=[], + next_page_token="def", ), service.ListAttestorsResponse( - attestors=[resources.Attestor(), resources.Attestor(),], + attestors=[ + resources.Attestor(), + ], + next_page_token="ghi", + ), + service.ListAttestorsResponse( + attestors=[ + resources.Attestor(), + resources.Attestor(), + ], ), RuntimeError, ) - async_pager = await client.list_attestors(request={},) + async_pager = await client.list_attestors( + 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 @@ -2143,26 +2307,44 @@ async def test_list_attestors_async_pages(): ], next_page_token="abc", ), - service.ListAttestorsResponse(attestors=[], next_page_token="def",), service.ListAttestorsResponse( - attestors=[resources.Attestor(),], next_page_token="ghi", + attestors=[], + next_page_token="def", ), service.ListAttestorsResponse( - attestors=[resources.Attestor(), resources.Attestor(),], + attestors=[ + resources.Attestor(), + ], + next_page_token="ghi", + ), + service.ListAttestorsResponse( + attestors=[ + resources.Attestor(), + resources.Attestor(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_attestors(request={})).pages: + async for page_ in ( + await client.list_attestors(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", [service.DeleteAttestorRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.DeleteAttestorRequest, + dict, + ], +) def test_delete_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2188,7 +2370,8 @@ def test_delete_attestor_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 = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2204,7 +2387,8 @@ async def test_delete_attestor_async( transport: str = "grpc_asyncio", request_type=service.DeleteAttestorRequest ): client = BinauthzManagementServiceV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2240,7 +2424,7 @@ def test_delete_attestor_field_headers(): # a field header. Set these to a non-empty value. request = service.DeleteAttestorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_attestor), "__call__") as call: @@ -2254,7 +2438,10 @@ def test_delete_attestor_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 @@ -2267,7 +2454,7 @@ async def test_delete_attestor_field_headers_async(): # a field header. Set these to a non-empty value. request = service.DeleteAttestorRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_attestor), "__call__") as call: @@ -2281,7 +2468,10 @@ async def test_delete_attestor_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_attestor_flattened(): @@ -2295,7 +2485,9 @@ def test_delete_attestor_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_attestor(name="name_value",) + client.delete_attestor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2315,7 +2507,8 @@ def test_delete_attestor_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.delete_attestor( - service.DeleteAttestorRequest(), name="name_value", + service.DeleteAttestorRequest(), + name="name_value", ) @@ -2333,7 +2526,9 @@ async def test_delete_attestor_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_attestor(name="name_value",) + response = await client.delete_attestor( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2354,7 +2549,8 @@ async def test_delete_attestor_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_attestor( - service.DeleteAttestorRequest(), name="name_value", + service.DeleteAttestorRequest(), + name="name_value", ) @@ -2365,7 +2561,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = BinauthzManagementServiceV1Beta1Client( - 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. @@ -2386,7 +2583,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = BinauthzManagementServiceV1Beta1Client( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -2403,7 +2601,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = BinauthzManagementServiceV1Beta1Client( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2446,13 +2645,29 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = BinauthzManagementServiceV1Beta1Client.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 = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( - client.transport, transports.BinauthzManagementServiceV1Beta1GrpcTransport, + client.transport, + transports.BinauthzManagementServiceV1Beta1GrpcTransport, ) @@ -2493,6 +2708,14 @@ def test_binauthz_management_service_v1_beta1_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_binauthz_management_service_v1_beta1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -2504,7 +2727,8 @@ def test_binauthz_management_service_v1_beta1_base_transport_with_credentials_fi Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.BinauthzManagementServiceV1Beta1Transport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2644,24 +2868,40 @@ def test_binauthz_management_service_v1_beta1_grpc_transport_client_cert_source_ ) -def test_binauthz_management_service_v1_beta1_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_binauthz_management_service_v1_beta1_host_no_port(transport_name): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") -def test_binauthz_management_service_v1_beta1_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_binauthz_management_service_v1_beta1_host_with_port(transport_name): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:8000" + assert client.transport._host == ("binaryauthorization.googleapis.com:8000") def test_binauthz_management_service_v1_beta1_grpc_transport_channel(): @@ -2669,7 +2909,8 @@ def test_binauthz_management_service_v1_beta1_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.BinauthzManagementServiceV1Beta1GrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2681,7 +2922,8 @@ def test_binauthz_management_service_v1_beta1_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.BinauthzManagementServiceV1Beta1GrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2794,7 +3036,8 @@ def test_attestor_path(): project = "squid" attestor = "clam" expected = "projects/{project}/attestors/{attestor}".format( - project=project, attestor=attestor, + project=project, + attestor=attestor, ) actual = BinauthzManagementServiceV1Beta1Client.attestor_path(project, attestor) assert expected == actual @@ -2814,7 +3057,9 @@ def test_parse_attestor_path(): def test_policy_path(): project = "oyster" - expected = "projects/{project}/policy".format(project=project,) + expected = "projects/{project}/policy".format( + project=project, + ) actual = BinauthzManagementServiceV1Beta1Client.policy_path(project) assert expected == actual @@ -2858,7 +3103,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = BinauthzManagementServiceV1Beta1Client.common_folder_path(folder) assert expected == actual @@ -2876,7 +3123,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = BinauthzManagementServiceV1Beta1Client.common_organization_path( organization ) @@ -2896,7 +3145,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = BinauthzManagementServiceV1Beta1Client.common_project_path(project) assert expected == actual @@ -2916,7 +3167,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = BinauthzManagementServiceV1Beta1Client.common_location_path( project, location @@ -2943,7 +3195,8 @@ def test_client_with_default_client_info(): transports.BinauthzManagementServiceV1Beta1Transport, "_prep_wrapped_messages" ) as prep: client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2952,7 +3205,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = BinauthzManagementServiceV1Beta1Client.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) @@ -2960,7 +3214,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = BinauthzManagementServiceV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py b/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py index 39d4ce9..f9d5e10 100644 --- a/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py +++ b/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -93,20 +99,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [SystemPolicyV1Beta1Client, SystemPolicyV1Beta1AsyncClient,] + "client_class,transport_name", + [ + (SystemPolicyV1Beta1Client, "grpc"), + (SystemPolicyV1Beta1AsyncClient, "grpc_asyncio"), + ], ) -def test_system_policy_v1_beta1_client_from_service_account_info(client_class): +def test_system_policy_v1_beta1_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") @pytest.mark.parametrize( @@ -135,23 +147,33 @@ def test_system_policy_v1_beta1_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [SystemPolicyV1Beta1Client, SystemPolicyV1Beta1AsyncClient,] + "client_class,transport_name", + [ + (SystemPolicyV1Beta1Client, "grpc"), + (SystemPolicyV1Beta1AsyncClient, "grpc_asyncio"), + ], ) -def test_system_policy_v1_beta1_client_from_service_account_file(client_class): +def test_system_policy_v1_beta1_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 == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") def test_system_policy_v1_beta1_client_get_transport_class(): @@ -517,7 +539,9 @@ def test_system_policy_v1_beta1_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) @@ -657,10 +681,17 @@ def test_system_policy_v1_beta1_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [service.GetSystemPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + service.GetSystemPolicyRequest, + dict, + ], +) def test_get_system_policy(request_type, transport: str = "grpc"): client = SystemPolicyV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -698,7 +729,8 @@ def test_get_system_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SystemPolicyV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -716,7 +748,8 @@ async def test_get_system_policy_async( transport: str = "grpc_asyncio", request_type=service.GetSystemPolicyRequest ): client = SystemPolicyV1Beta1AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -766,7 +799,7 @@ def test_get_system_policy_field_headers(): # a field header. Set these to a non-empty value. request = service.GetSystemPolicyRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -782,7 +815,10 @@ def test_get_system_policy_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 @@ -795,7 +831,7 @@ async def test_get_system_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetSystemPolicyRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -811,7 +847,10 @@ async def test_get_system_policy_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_system_policy_flattened(): @@ -827,7 +866,9 @@ def test_get_system_policy_flattened(): call.return_value = resources.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_system_policy(name="name_value",) + client.get_system_policy( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -847,7 +888,8 @@ def test_get_system_policy_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_system_policy( - service.GetSystemPolicyRequest(), name="name_value", + service.GetSystemPolicyRequest(), + name="name_value", ) @@ -867,7 +909,9 @@ async def test_get_system_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_system_policy(name="name_value",) + response = await client.get_system_policy( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -888,7 +932,8 @@ async def test_get_system_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_system_policy( - service.GetSystemPolicyRequest(), name="name_value", + service.GetSystemPolicyRequest(), + name="name_value", ) @@ -899,7 +944,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SystemPolicyV1Beta1Client( - 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. @@ -919,7 +965,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = SystemPolicyV1Beta1Client(client_options=options, transport=transport,) + client = SystemPolicyV1Beta1Client( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -935,7 +984,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SystemPolicyV1Beta1Client( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -978,12 +1028,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = SystemPolicyV1Beta1Client.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 = SystemPolicyV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), ) - assert isinstance(client.transport, transports.SystemPolicyV1Beta1GrpcTransport,) + assert isinstance( + client.transport, + transports.SystemPolicyV1Beta1GrpcTransport, + ) def test_system_policy_v1_beta1_base_transport_error(): @@ -1015,6 +1081,14 @@ def test_system_policy_v1_beta1_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_system_policy_v1_beta1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1026,7 +1100,8 @@ def test_system_policy_v1_beta1_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SystemPolicyV1Beta1Transport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1161,24 +1236,40 @@ def test_system_policy_v1_beta1_grpc_transport_client_cert_source_for_mtls( ) -def test_system_policy_v1_beta1_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_system_policy_v1_beta1_host_no_port(transport_name): client = SystemPolicyV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:443" + assert client.transport._host == ("binaryauthorization.googleapis.com:443") -def test_system_policy_v1_beta1_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_system_policy_v1_beta1_host_with_port(transport_name): client = SystemPolicyV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="binaryauthorization.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "binaryauthorization.googleapis.com:8000" + assert client.transport._host == ("binaryauthorization.googleapis.com:8000") def test_system_policy_v1_beta1_grpc_transport_channel(): @@ -1186,7 +1277,8 @@ def test_system_policy_v1_beta1_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.SystemPolicyV1Beta1GrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1198,7 +1290,8 @@ def test_system_policy_v1_beta1_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.SystemPolicyV1Beta1GrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1307,7 +1400,9 @@ def test_system_policy_v1_beta1_transport_channel_mtls_with_adc(transport_class) def test_policy_path(): project = "squid" - expected = "projects/{project}/policy".format(project=project,) + expected = "projects/{project}/policy".format( + project=project, + ) actual = SystemPolicyV1Beta1Client.policy_path(project) assert expected == actual @@ -1345,7 +1440,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = SystemPolicyV1Beta1Client.common_folder_path(folder) assert expected == actual @@ -1363,7 +1460,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = SystemPolicyV1Beta1Client.common_organization_path(organization) assert expected == actual @@ -1381,7 +1480,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = SystemPolicyV1Beta1Client.common_project_path(project) assert expected == actual @@ -1401,7 +1502,8 @@ def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = SystemPolicyV1Beta1Client.common_location_path(project, location) assert expected == actual @@ -1426,7 +1528,8 @@ def test_client_with_default_client_info(): transports.SystemPolicyV1Beta1Transport, "_prep_wrapped_messages" ) as prep: client = SystemPolicyV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1435,7 +1538,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = SystemPolicyV1Beta1Client.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) @@ -1443,7 +1547,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = SystemPolicyV1Beta1AsyncClient( - 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"