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 7e08e05..b631901 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:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae + digest: sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149 +# created: 2022-05-05T15:17:27.599381182Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 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..29601ad 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,11 @@ 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: v1 + handleGHRelease: true + releaseType: python +- 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 923d316..fbf6fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [2.8.0](https://github.com/googleapis/python-containeranalysis/compare/v2.7.3...v2.8.0) (2022-05-05) + + +### Features + +* AuditConfig for IAM v1 ([dfb21df](https://github.com/googleapis/python-containeranalysis/commit/dfb21df83a30d33f31dc67b8a50cc5d5cf9e9ccf)) + + +### Bug Fixes + +* **deps:** require grpc-google-iam-v1 >=0.12.4 ([dfb21df](https://github.com/googleapis/python-containeranalysis/commit/dfb21df83a30d33f31dc67b8a50cc5d5cf9e9ccf)) + ### [2.7.3](https://github.com/googleapis/python-containeranalysis/compare/v2.7.2...v2.7.3) (2022-03-07) diff --git a/docs/conf.py b/docs/conf.py index 5f8a9ac..c6405fc 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/devtools/containeranalysis_v1/services/container_analysis/async_client.py b/google/cloud/devtools/containeranalysis_v1/services/container_analysis/async_client.py index 82e9826..2296c8c 100644 --- a/google/cloud/devtools/containeranalysis_v1/services/container_analysis/async_client.py +++ b/google/cloud/devtools/containeranalysis_v1/services/container_analysis/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 @@ -253,22 +253,22 @@ async def set_iam_policy( ``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for occurrences. - .. code-block:: python from google.cloud.devtools import containeranalysis_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_set_iam_policy(): + async def sample_set_iam_policy(): # Create a client - client = containeranalysis_v1.ContainerAnalysisClient() + client = containeranalysis_v1.ContainerAnalysisAsyncClient() # Initialize request argument(s) - request = containeranalysis_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.set_iam_policy(request=request) + response = await client.set_iam_policy(request=request) # Handle the response print(response) @@ -294,21 +294,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -323,17 +328,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -344,11 +349,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -366,7 +372,9 @@ def sample_set_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.SetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -383,7 +391,12 @@ def sample_set_iam_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 @@ -407,22 +420,22 @@ async def get_iam_policy( ``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for occurrences. - .. code-block:: python from google.cloud.devtools import containeranalysis_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_get_iam_policy(): + async def sample_get_iam_policy(): # Create a client - client = containeranalysis_v1.ContainerAnalysisClient() + client = containeranalysis_v1.ContainerAnalysisAsyncClient() # Initialize request argument(s) - request = containeranalysis_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.get_iam_policy(request=request) + response = await client.get_iam_policy(request=request) # Handle the response print(response) @@ -448,21 +461,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -477,17 +495,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -498,11 +516,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -520,7 +539,9 @@ def sample_get_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.GetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -537,7 +558,12 @@ def sample_get_iam_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 @@ -561,23 +587,23 @@ async def test_iam_permissions( ``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for occurrences. - .. code-block:: python from google.cloud.devtools import containeranalysis_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_test_iam_permissions(): + async def sample_test_iam_permissions(): # Create a client - client = containeranalysis_v1.ContainerAnalysisClient() + client = containeranalysis_v1.ContainerAnalysisAsyncClient() # Initialize request argument(s) - request = containeranalysis_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) # Make the request - response = client.test_iam_permissions(request=request) + response = await client.test_iam_permissions(request=request) # Handle the response print(response) @@ -630,7 +656,8 @@ def sample_test_iam_permissions(): request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: request = iam_policy_pb2.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -648,7 +675,12 @@ def sample_test_iam_permissions(): ) # 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 @@ -668,14 +700,13 @@ async def get_vulnerability_occurrences_summary( r"""Gets a summary of the number and severity of occurrences. - .. code-block:: python from google.cloud.devtools import containeranalysis_v1 - def sample_get_vulnerability_occurrences_summary(): + async def sample_get_vulnerability_occurrences_summary(): # Create a client - client = containeranalysis_v1.ContainerAnalysisClient() + client = containeranalysis_v1.ContainerAnalysisAsyncClient() # Initialize request argument(s) request = containeranalysis_v1.GetVulnerabilityOccurrencesSummaryRequest( @@ -683,7 +714,7 @@ def sample_get_vulnerability_occurrences_summary(): ) # Make the request - response = client.get_vulnerability_occurrences_summary(request=request) + response = await client.get_vulnerability_occurrences_summary(request=request) # Handle the response print(response) @@ -751,7 +782,12 @@ def sample_get_vulnerability_occurrences_summary(): ) # 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/devtools/containeranalysis_v1/services/container_analysis/client.py b/google/cloud/devtools/containeranalysis_v1/services/container_analysis/client.py index 7884537..47d4f97 100644 --- a/google/cloud/devtools/containeranalysis_v1/services/container_analysis/client.py +++ b/google/cloud/devtools/containeranalysis_v1/services/container_analysis/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 @@ -61,7 +61,8 @@ class ContainerAnalysisClientMeta(type): _transport_registry["grpc_asyncio"] = ContainerAnalysisGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[ContainerAnalysisTransport]: """Returns an appropriate transport class. @@ -182,7 +183,9 @@ def transport(self) -> ContainerAnalysisTransport: 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, @@ -195,9 +198,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]: @@ -206,9 +213,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]: @@ -217,9 +228,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]: @@ -228,10 +243,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 @@ -438,17 +457,17 @@ def set_iam_policy( ``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for occurrences. - .. code-block:: python from google.cloud.devtools import containeranalysis_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = containeranalysis_v1.ContainerAnalysisClient() # Initialize request argument(s) - request = containeranalysis_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -479,21 +498,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -508,17 +532,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -529,11 +553,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -567,7 +592,12 @@ def sample_set_iam_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 @@ -591,17 +621,17 @@ def get_iam_policy( ``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for occurrences. - .. code-block:: python from google.cloud.devtools import containeranalysis_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = containeranalysis_v1.ContainerAnalysisClient() # Initialize request argument(s) - request = containeranalysis_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -632,21 +662,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -661,17 +696,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -682,11 +717,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -720,7 +756,12 @@ def sample_get_iam_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 @@ -744,17 +785,17 @@ def test_iam_permissions( ``projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`` for occurrences. - .. code-block:: python from google.cloud.devtools import containeranalysis_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = containeranalysis_v1.ContainerAnalysisClient() # Initialize request argument(s) - request = containeranalysis_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) @@ -830,7 +871,12 @@ def sample_test_iam_permissions(): ) # 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 @@ -850,7 +896,6 @@ def get_vulnerability_occurrences_summary( r"""Gets a summary of the number and severity of occurrences. - .. code-block:: python from google.cloud.devtools import containeranalysis_v1 @@ -939,7 +984,12 @@ def sample_get_vulnerability_occurrences_summary(): ) # 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/devtools/containeranalysis_v1/services/container_analysis/transports/base.py b/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/base.py index 46455c5..5f9a3aa 100644 --- a/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/base.py +++ b/google/cloud/devtools/containeranalysis_v1/services/container_analysis/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" @@ -123,10 +124,14 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=30.0, client_info=client_info, + self.set_iam_policy, + default_timeout=30.0, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( - self.get_iam_policy, default_timeout=30.0, client_info=client_info, + self.get_iam_policy, + default_timeout=30.0, + client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, @@ -143,9 +148,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() @@ -191,5 +196,9 @@ def get_vulnerability_occurrences_summary( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("ContainerAnalysisTransport",) diff --git a/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/grpc.py b/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/grpc.py index 4fdb590..49a1c0c 100644 --- a/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/grpc.py +++ b/google/cloud/devtools/containeranalysis_v1/services/container_analysis/transports/grpc.py @@ -240,8 +240,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 @@ -384,5 +383,9 @@ def get_vulnerability_occurrences_summary( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("ContainerAnalysisGrpcTransport",) diff --git a/google/cloud/devtools/containeranalysis_v1/types/containeranalysis.py b/google/cloud/devtools/containeranalysis_v1/types/containeranalysis.py index 49bc172..4480a7a 100644 --- a/google/cloud/devtools/containeranalysis_v1/types/containeranalysis.py +++ b/google/cloud/devtools/containeranalysis_v1/types/containeranalysis.py @@ -39,8 +39,14 @@ class GetVulnerabilityOccurrencesSummaryRequest(proto.Message): The filter expression. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) class VulnerabilityOccurrencesSummary(proto.Message): @@ -71,12 +77,29 @@ class FixableTotalByDigest(proto.Message): associated with this resource. """ - resource_uri = proto.Field(proto.STRING, number=1,) - severity = proto.Field(proto.ENUM, number=2, enum=severity.Severity,) - fixable_count = proto.Field(proto.INT64, number=3,) - total_count = proto.Field(proto.INT64, number=4,) - - counts = proto.RepeatedField(proto.MESSAGE, number=1, message=FixableTotalByDigest,) + resource_uri = proto.Field( + proto.STRING, + number=1, + ) + severity = proto.Field( + proto.ENUM, + number=2, + enum=severity.Severity, + ) + fixable_count = proto.Field( + proto.INT64, + number=3, + ) + total_count = proto.Field( + proto.INT64, + number=4, + ) + + counts = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=FixableTotalByDigest, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index f041f1f..c64eb80 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 2815408..6b2c822 100644 --- a/owlbot.py +++ b/owlbot.py @@ -166,6 +166,7 @@ ] ) +python.configure_previous_major_version_branches() python.py_samples(skip_readmes=True) s.shell.run(["nox", "-s", "blacken"], hide_output=False) \ No newline at end of file diff --git a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_get_iam_policy_async.py b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_get_iam_policy_async.py index bfdef6e..536404e 100644 --- a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_get_iam_policy_async.py +++ b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_get_iam_policy_async.py @@ -25,6 +25,7 @@ # [START containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_async] from google.cloud.devtools import containeranalysis_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): @@ -32,7 +33,7 @@ async def sample_get_iam_policy(): client = containeranalysis_v1.ContainerAnalysisAsyncClient() # Initialize request argument(s) - request = containeranalysis_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_get_iam_policy_sync.py b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_get_iam_policy_sync.py index 493a3d5..ecdab95 100644 --- a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_get_iam_policy_sync.py +++ b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_get_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_sync] from google.cloud.devtools import containeranalysis_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): @@ -32,7 +33,7 @@ def sample_get_iam_policy(): client = containeranalysis_v1.ContainerAnalysisClient() # Initialize request argument(s) - request = containeranalysis_v1.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_set_iam_policy_async.py b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_set_iam_policy_async.py index e520e67..0e3ca01 100644 --- a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_set_iam_policy_async.py +++ b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_set_iam_policy_async.py @@ -25,6 +25,7 @@ # [START containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_async] from google.cloud.devtools import containeranalysis_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): @@ -32,7 +33,7 @@ async def sample_set_iam_policy(): client = containeranalysis_v1.ContainerAnalysisAsyncClient() # Initialize request argument(s) - request = containeranalysis_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_set_iam_policy_sync.py b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_set_iam_policy_sync.py index db8745c..ef4711e 100644 --- a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_set_iam_policy_sync.py +++ b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_set_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_sync] from google.cloud.devtools import containeranalysis_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): @@ -32,7 +33,7 @@ def sample_set_iam_policy(): client = containeranalysis_v1.ContainerAnalysisClient() # Initialize request argument(s) - request = containeranalysis_v1.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_test_iam_permissions_async.py b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_test_iam_permissions_async.py index 5e8db9a..39642af 100644 --- a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_test_iam_permissions_async.py +++ b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_test_iam_permissions_async.py @@ -25,6 +25,7 @@ # [START containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_async] from google.cloud.devtools import containeranalysis_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ async def sample_test_iam_permissions(): client = containeranalysis_v1.ContainerAnalysisAsyncClient() # Initialize request argument(s) - request = containeranalysis_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_test_iam_permissions_sync.py b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_test_iam_permissions_sync.py index ba04d50..f775ec9 100644 --- a/samples/generated_samples/containeranalysis_v1_generated_container_analysis_test_iam_permissions_sync.py +++ b/samples/generated_samples/containeranalysis_v1_generated_container_analysis_test_iam_permissions_sync.py @@ -25,6 +25,7 @@ # [START containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_sync] from google.cloud.devtools import containeranalysis_v1 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ def sample_test_iam_permissions(): client = containeranalysis_v1.ContainerAnalysisClient() # Initialize request argument(s) - request = containeranalysis_v1.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/snippet_metadata_containeranalysis_v1.json b/samples/generated_samples/snippet_metadata_containeranalysis_v1.json index e0b3471..3d8d03f 100644 --- a/samples/generated_samples/snippet_metadata_containeranalysis_v1.json +++ b/samples/generated_samples/snippet_metadata_containeranalysis_v1.json @@ -1,105 +1,226 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.devtools.containeranalysis.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-devtools-containeranalysis" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisAsyncClient", + "shortName": "ContainerAnalysisAsyncClient" + }, + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisAsyncClient.get_iam_policy", "method": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis.GetIamPolicy", "service": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis", "shortName": "ContainerAnalysis" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "containeranalysis_v1_generated_container_analysis_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "containeranalysis_v1_generated_container_analysis_get_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisClient", + "shortName": "ContainerAnalysisClient" + }, + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisClient.get_iam_policy", "method": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis.GetIamPolicy", "service": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis", "shortName": "ContainerAnalysis" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "containeranalysis_v1_generated_container_analysis_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "containeranalysis_v1_generated_container_analysis_get_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisAsyncClient", + "shortName": "ContainerAnalysisAsyncClient" + }, + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisAsyncClient.get_vulnerability_occurrences_summary", "method": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis.GetVulnerabilityOccurrencesSummary", "service": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis", "shortName": "ContainerAnalysis" }, "shortName": "GetVulnerabilityOccurrencesSummary" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.containeranalysis_v1.types.GetVulnerabilityOccurrencesSummaryRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.containeranalysis_v1.types.VulnerabilityOccurrencesSummary", + "shortName": "get_vulnerability_occurrences_summary" }, + "description": "Sample for GetVulnerabilityOccurrencesSummary", "file": "containeranalysis_v1_generated_container_analysis_get_vulnerability_occurrences_summary_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "containeranalysis_v1_generated_ContainerAnalysis_GetVulnerabilityOccurrencesSummary_async", "segments": [ { @@ -132,18 +253,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "containeranalysis_v1_generated_container_analysis_get_vulnerability_occurrences_summary_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisClient", + "shortName": "ContainerAnalysisClient" + }, + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisClient.get_vulnerability_occurrences_summary", "method": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis.GetVulnerabilityOccurrencesSummary", "service": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis", "shortName": "ContainerAnalysis" }, "shortName": "GetVulnerabilityOccurrencesSummary" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.containeranalysis_v1.types.GetVulnerabilityOccurrencesSummaryRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.containeranalysis_v1.types.VulnerabilityOccurrencesSummary", + "shortName": "get_vulnerability_occurrences_summary" }, + "description": "Sample for GetVulnerabilityOccurrencesSummary", "file": "containeranalysis_v1_generated_container_analysis_get_vulnerability_occurrences_summary_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "containeranalysis_v1_generated_ContainerAnalysis_GetVulnerabilityOccurrencesSummary_sync", "segments": [ { @@ -176,185 +337,338 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "containeranalysis_v1_generated_container_analysis_get_vulnerability_occurrences_summary_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisAsyncClient", + "shortName": "ContainerAnalysisAsyncClient" + }, + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisAsyncClient.set_iam_policy", "method": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis.SetIamPolicy", "service": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis", "shortName": "ContainerAnalysis" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "containeranalysis_v1_generated_container_analysis_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "containeranalysis_v1_generated_container_analysis_set_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisClient", + "shortName": "ContainerAnalysisClient" + }, + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisClient.set_iam_policy", "method": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis.SetIamPolicy", "service": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis", "shortName": "ContainerAnalysis" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "containeranalysis_v1_generated_container_analysis_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "containeranalysis_v1_generated_container_analysis_set_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisAsyncClient", + "shortName": "ContainerAnalysisAsyncClient" + }, + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisAsyncClient.test_iam_permissions", "method": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis.TestIamPermissions", "service": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis", "shortName": "ContainerAnalysis" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "containeranalysis_v1_generated_container_analysis_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_async", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "containeranalysis_v1_generated_container_analysis_test_iam_permissions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisClient", + "shortName": "ContainerAnalysisClient" + }, + "fullName": "google.cloud.devtools.containeranalysis_v1.ContainerAnalysisClient.test_iam_permissions", "method": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis.TestIamPermissions", "service": { + "fullName": "google.devtools.containeranalysis.v1.ContainerAnalysis", "shortName": "ContainerAnalysis" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "containeranalysis_v1_generated_container_analysis_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_sync", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "containeranalysis_v1_generated_container_analysis_test_iam_permissions_sync.py" } ] } diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 4c808af..38bb0a5 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -29,7 +29,8 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -168,12 +169,32 @@ def lint(session: nox.sessions.Session) -> None: @nox.session def blacken(session: nox.sessions.Session) -> None: + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) python_files = [path for path in os.listdir(".") if path.endswith(".py")] session.run("black", *python_files) +# +# format = isort + black +# + +@nox.session +def format(session: nox.sessions.Session) -> None: + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run("isort", "--fss", *python_files) + session.run("black", *python_files) + + # # Sample Tests # diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index c2845bf..d00689e 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1 +1 @@ -pytest==7.0.1 +pytest==7.1.2 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 3edf835..8ed3df3 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,6 +1,6 @@ -google-cloud-pubsub==2.10.0 -google-cloud-containeranalysis==2.7.2 +google-cloud-pubsub==2.12.0 +google-cloud-containeranalysis==2.7.3 grafeas==1.4.3 -pytest==7.0.1 +pytest==7.1.2 flaky==3.7.0 mock==4.0.3 diff --git a/scripts/fixup_containeranalysis_v1_keywords.py b/scripts/fixup_containeranalysis_v1_keywords.py index cf3c782..6ff3a0e 100644 --- a/scripts/fixup_containeranalysis_v1_keywords.py +++ b/scripts/fixup_containeranalysis_v1_keywords.py @@ -41,7 +41,7 @@ class containeranalysisCallTransformer(cst.CSTTransformer): METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'get_iam_policy': ('resource', 'options', ), 'get_vulnerability_occurrences_summary': ('parent', 'filter', ), - 'set_iam_policy': ('resource', 'policy', ), + 'set_iam_policy': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions': ('resource', 'permissions', ), } 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 5030bdc..950d210 100644 --- a/setup.py +++ b/setup.py @@ -22,14 +22,14 @@ name = "google-cloud-containeranalysis" description = "Container Analysis API API client library" -version = "2.7.3" +version = "2.8.0" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # 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", - "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", + "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", "proto-plus >= 1.15.0", "grafeas >=1.4.1, <2.0dev", ] diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index a0c65cc..a9d02d6 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -6,7 +6,7 @@ # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 google-api-core==1.31.5 -grpc-google-iam-v1==0.12.3 +grpc-google-iam-v1==0.12.4 proto-plus==1.15.0 libcst==0.2.5 grafeas==1.4.1 diff --git a/tests/unit/gapic/containeranalysis_v1/test_container_analysis.py b/tests/unit/gapic/containeranalysis_v1/test_container_analysis.py index f660d72..cdb3994 100644 --- a/tests/unit/gapic/containeranalysis_v1/test_container_analysis.py +++ b/tests/unit/gapic/containeranalysis_v1/test_container_analysis.py @@ -45,6 +45,7 @@ from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore from google.type import expr_pb2 # type: ignore import google.auth @@ -95,20 +96,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [ContainerAnalysisClient, ContainerAnalysisAsyncClient,] + "client_class,transport_name", + [ + (ContainerAnalysisClient, "grpc"), + (ContainerAnalysisAsyncClient, "grpc_asyncio"), + ], ) -def test_container_analysis_client_from_service_account_info(client_class): +def test_container_analysis_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 == "containeranalysis.googleapis.com:443" + assert client.transport._host == ("containeranalysis.googleapis.com:443") @pytest.mark.parametrize( @@ -137,23 +144,33 @@ def test_container_analysis_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [ContainerAnalysisClient, ContainerAnalysisAsyncClient,] + "client_class,transport_name", + [ + (ContainerAnalysisClient, "grpc"), + (ContainerAnalysisAsyncClient, "grpc_asyncio"), + ], ) -def test_container_analysis_client_from_service_account_file(client_class): +def test_container_analysis_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 == "containeranalysis.googleapis.com:443" + assert client.transport._host == ("containeranalysis.googleapis.com:443") def test_container_analysis_client_get_transport_class(): @@ -511,7 +528,9 @@ def test_container_analysis_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) @@ -654,10 +673,17 @@ def test_container_analysis_client_create_channel_credentials_file( assert file_creds == client.get_grafeas_client().transport._credentials -@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) def test_set_iam_policy(request_type, transport: str = "grpc"): client = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -667,7 +693,10 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -685,7 +714,8 @@ def test_set_iam_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 = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -701,7 +731,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = ContainerAnalysisAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -712,7 +743,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -733,13 +767,15 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + 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 = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -753,7 +789,10 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -766,7 +805,7 @@ async def test_set_iam_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -780,11 +819,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -793,13 +837,16 @@ def test_set_iam_policy_from_dict_foreign(): request={ "resource": "resource_value", "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), } ) call.assert_called() def test_set_iam_policy_flattened(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -807,7 +854,9 @@ def test_set_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -819,13 +868,16 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + 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.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @@ -843,7 +895,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -864,14 +918,22 @@ async def test_set_iam_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) def test_get_iam_policy(request_type, transport: str = "grpc"): client = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -881,7 +943,10 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -899,7 +964,8 @@ def test_get_iam_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 = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -915,7 +981,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = ContainerAnalysisAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -926,7 +993,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -947,13 +1017,15 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + 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 = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -967,7 +1039,10 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -980,7 +1055,7 @@ async def test_get_iam_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -994,11 +1069,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -1013,7 +1093,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -1021,7 +1103,9 @@ def test_get_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1033,13 +1117,16 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + 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_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @@ -1057,7 +1144,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1078,16 +1167,22 @@ async def test_get_iam_policy_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.parametrize( - "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], ) def test_test_iam_permissions(request_type, transport: str = "grpc"): client = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1118,7 +1213,8 @@ def test_test_iam_permissions_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 = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1137,7 +1233,8 @@ async def test_test_iam_permissions_async( request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = ContainerAnalysisAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1172,13 +1269,15 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + 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 = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1194,7 +1293,10 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1207,7 +1309,7 @@ async def test_test_iam_permissions_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1225,11 +1327,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -1246,7 +1353,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1257,7 +1366,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -1273,7 +1383,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1304,7 +1416,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -1336,11 +1449,16 @@ async def test_test_iam_permissions_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [containeranalysis.GetVulnerabilityOccurrencesSummaryRequest, dict,] + "request_type", + [ + containeranalysis.GetVulnerabilityOccurrencesSummaryRequest, + dict, + ], ) def test_get_vulnerability_occurrences_summary(request_type, transport: str = "grpc"): client = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1368,7 +1486,8 @@ def test_get_vulnerability_occurrences_summary_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 = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1387,7 +1506,8 @@ async def test_get_vulnerability_occurrences_summary_async( request_type=containeranalysis.GetVulnerabilityOccurrencesSummaryRequest, ): client = ContainerAnalysisAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1419,13 +1539,15 @@ async def test_get_vulnerability_occurrences_summary_async_from_dict(): def test_get_vulnerability_occurrences_summary_field_headers(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + 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 = containeranalysis.GetVulnerabilityOccurrencesSummaryRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1441,7 +1563,10 @@ def test_get_vulnerability_occurrences_summary_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 @@ -1454,7 +1579,7 @@ async def test_get_vulnerability_occurrences_summary_field_headers_async(): # a field header. Set these to a non-empty value. request = containeranalysis.GetVulnerabilityOccurrencesSummaryRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1472,11 +1597,16 @@ async def test_get_vulnerability_occurrences_summary_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_get_vulnerability_occurrences_summary_flattened(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1487,7 +1617,8 @@ def test_get_vulnerability_occurrences_summary_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_vulnerability_occurrences_summary( - parent="parent_value", filter="filter_value", + parent="parent_value", + filter="filter_value", ) # Establish that the underlying call was made with the expected @@ -1503,7 +1634,9 @@ def test_get_vulnerability_occurrences_summary_flattened(): def test_get_vulnerability_occurrences_summary_flattened_error(): - client = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1534,7 +1667,8 @@ async def test_get_vulnerability_occurrences_summary_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.get_vulnerability_occurrences_summary( - parent="parent_value", filter="filter_value", + parent="parent_value", + filter="filter_value", ) # Establish that the underlying call was made with the expected @@ -1572,7 +1706,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = ContainerAnalysisClient( - 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. @@ -1592,7 +1727,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = ContainerAnalysisClient(client_options=options, transport=transport,) + client = ContainerAnalysisClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1608,7 +1746,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = ContainerAnalysisClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1651,10 +1790,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = ContainerAnalysisClient.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 = ContainerAnalysisClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.ContainerAnalysisGrpcTransport,) + client = ContainerAnalysisClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.ContainerAnalysisGrpcTransport, + ) def test_container_analysis_base_transport_error(): @@ -1691,6 +1848,14 @@ def test_container_analysis_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_container_analysis_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1702,7 +1867,8 @@ def test_container_analysis_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ContainerAnalysisTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1835,24 +2001,40 @@ def test_container_analysis_grpc_transport_client_cert_source_for_mtls(transport ) -def test_container_analysis_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_container_analysis_host_no_port(transport_name): client = ContainerAnalysisClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="containeranalysis.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "containeranalysis.googleapis.com:443" + assert client.transport._host == ("containeranalysis.googleapis.com:443") -def test_container_analysis_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_container_analysis_host_with_port(transport_name): client = ContainerAnalysisClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="containeranalysis.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "containeranalysis.googleapis.com:8000" + assert client.transport._host == ("containeranalysis.googleapis.com:8000") def test_container_analysis_grpc_transport_channel(): @@ -1860,7 +2042,8 @@ def test_container_analysis_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.ContainerAnalysisGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1872,7 +2055,8 @@ def test_container_analysis_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.ContainerAnalysisGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2001,7 +2185,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 = ContainerAnalysisClient.common_folder_path(folder) assert expected == actual @@ -2019,7 +2205,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 = ContainerAnalysisClient.common_organization_path(organization) assert expected == actual @@ -2037,7 +2225,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 = ContainerAnalysisClient.common_project_path(project) assert expected == actual @@ -2057,7 +2247,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 = ContainerAnalysisClient.common_location_path(project, location) assert expected == actual @@ -2082,7 +2273,8 @@ def test_client_with_default_client_info(): transports.ContainerAnalysisTransport, "_prep_wrapped_messages" ) as prep: client = ContainerAnalysisClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2091,7 +2283,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = ContainerAnalysisClient.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) @@ -2099,7 +2292,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = ContainerAnalysisAsyncClient( - 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"