diff --git a/docs/artifactregistry_v1beta2/artifact_registry.rst b/docs/artifactregistry_v1beta2/artifact_registry.rst index 92a6e19..f067de3 100644 --- a/docs/artifactregistry_v1beta2/artifact_registry.rst +++ b/docs/artifactregistry_v1beta2/artifact_registry.rst @@ -5,7 +5,6 @@ ArtifactRegistry :members: :inherited-members: - .. automodule:: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers :members: :inherited-members: diff --git a/google/cloud/artifactregistry/__init__.py b/google/cloud/artifactregistry/__init__.py index 7fe6d1e..22946d2 100644 --- a/google/cloud/artifactregistry/__init__.py +++ b/google/cloud/artifactregistry/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,12 +14,13 @@ # limitations under the License. # -from google.cloud.artifactregistry_v1beta2.services.artifact_registry.async_client import ( - ArtifactRegistryAsyncClient, -) from google.cloud.artifactregistry_v1beta2.services.artifact_registry.client import ( ArtifactRegistryClient, ) +from google.cloud.artifactregistry_v1beta2.services.artifact_registry.async_client import ( + ArtifactRegistryAsyncClient, +) + from google.cloud.artifactregistry_v1beta2.types.file import File from google.cloud.artifactregistry_v1beta2.types.file import GetFileRequest from google.cloud.artifactregistry_v1beta2.types.file import Hash @@ -64,37 +64,37 @@ from google.cloud.artifactregistry_v1beta2.types.version import VersionView __all__ = ( - "ArtifactRegistryAsyncClient", "ArtifactRegistryClient", - "CreateRepositoryRequest", - "CreateTagRequest", - "DeletePackageRequest", - "DeleteRepositoryRequest", - "DeleteTagRequest", - "DeleteVersionRequest", + "ArtifactRegistryAsyncClient", "File", "GetFileRequest", - "GetPackageRequest", - "GetRepositoryRequest", - "GetTagRequest", - "GetVersionRequest", "Hash", "ListFilesRequest", "ListFilesResponse", + "DeletePackageRequest", + "GetPackageRequest", "ListPackagesRequest", "ListPackagesResponse", + "Package", + "CreateRepositoryRequest", + "DeleteRepositoryRequest", + "GetRepositoryRequest", "ListRepositoriesRequest", "ListRepositoriesResponse", + "Repository", + "UpdateRepositoryRequest", + "OperationMetadata", + "CreateTagRequest", + "DeleteTagRequest", + "GetTagRequest", "ListTagsRequest", "ListTagsResponse", - "ListVersionsRequest", - "ListVersionsResponse", - "OperationMetadata", - "Package", - "Repository", "Tag", - "UpdateRepositoryRequest", "UpdateTagRequest", + "DeleteVersionRequest", + "GetVersionRequest", + "ListVersionsRequest", + "ListVersionsResponse", "Version", "VersionView", ) diff --git a/google/cloud/artifactregistry_v1beta2/__init__.py b/google/cloud/artifactregistry_v1beta2/__init__.py index 7817852..856c9b2 100644 --- a/google/cloud/artifactregistry_v1beta2/__init__.py +++ b/google/cloud/artifactregistry_v1beta2/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +15,8 @@ # from .services.artifact_registry import ArtifactRegistryClient +from .services.artifact_registry import ArtifactRegistryAsyncClient + from .types.file import File from .types.file import GetFileRequest from .types.file import Hash @@ -48,8 +49,9 @@ from .types.version import Version from .types.version import VersionView - __all__ = ( + "ArtifactRegistryAsyncClient", + "ArtifactRegistryClient", "CreateRepositoryRequest", "CreateTagRequest", "DeletePackageRequest", @@ -81,5 +83,4 @@ "UpdateTagRequest", "Version", "VersionView", - "ArtifactRegistryClient", ) diff --git a/google/cloud/artifactregistry_v1beta2/gapic_metadata.json b/google/cloud/artifactregistry_v1beta2/gapic_metadata.json new file mode 100644 index 0000000..4daed8e --- /dev/null +++ b/google/cloud/artifactregistry_v1beta2/gapic_metadata.json @@ -0,0 +1,233 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.artifactregistry_v1beta2", + "protoPackage": "google.devtools.artifactregistry.v1beta2", + "schema": "1.0", + "services": { + "ArtifactRegistry": { + "clients": { + "grpc": { + "libraryClient": "ArtifactRegistryClient", + "rpcs": { + "CreateRepository": { + "methods": [ + "create_repository" + ] + }, + "CreateTag": { + "methods": [ + "create_tag" + ] + }, + "DeletePackage": { + "methods": [ + "delete_package" + ] + }, + "DeleteRepository": { + "methods": [ + "delete_repository" + ] + }, + "DeleteTag": { + "methods": [ + "delete_tag" + ] + }, + "DeleteVersion": { + "methods": [ + "delete_version" + ] + }, + "GetFile": { + "methods": [ + "get_file" + ] + }, + "GetIamPolicy": { + "methods": [ + "get_iam_policy" + ] + }, + "GetPackage": { + "methods": [ + "get_package" + ] + }, + "GetRepository": { + "methods": [ + "get_repository" + ] + }, + "GetTag": { + "methods": [ + "get_tag" + ] + }, + "GetVersion": { + "methods": [ + "get_version" + ] + }, + "ListFiles": { + "methods": [ + "list_files" + ] + }, + "ListPackages": { + "methods": [ + "list_packages" + ] + }, + "ListRepositories": { + "methods": [ + "list_repositories" + ] + }, + "ListTags": { + "methods": [ + "list_tags" + ] + }, + "ListVersions": { + "methods": [ + "list_versions" + ] + }, + "SetIamPolicy": { + "methods": [ + "set_iam_policy" + ] + }, + "TestIamPermissions": { + "methods": [ + "test_iam_permissions" + ] + }, + "UpdateRepository": { + "methods": [ + "update_repository" + ] + }, + "UpdateTag": { + "methods": [ + "update_tag" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ArtifactRegistryAsyncClient", + "rpcs": { + "CreateRepository": { + "methods": [ + "create_repository" + ] + }, + "CreateTag": { + "methods": [ + "create_tag" + ] + }, + "DeletePackage": { + "methods": [ + "delete_package" + ] + }, + "DeleteRepository": { + "methods": [ + "delete_repository" + ] + }, + "DeleteTag": { + "methods": [ + "delete_tag" + ] + }, + "DeleteVersion": { + "methods": [ + "delete_version" + ] + }, + "GetFile": { + "methods": [ + "get_file" + ] + }, + "GetIamPolicy": { + "methods": [ + "get_iam_policy" + ] + }, + "GetPackage": { + "methods": [ + "get_package" + ] + }, + "GetRepository": { + "methods": [ + "get_repository" + ] + }, + "GetTag": { + "methods": [ + "get_tag" + ] + }, + "GetVersion": { + "methods": [ + "get_version" + ] + }, + "ListFiles": { + "methods": [ + "list_files" + ] + }, + "ListPackages": { + "methods": [ + "list_packages" + ] + }, + "ListRepositories": { + "methods": [ + "list_repositories" + ] + }, + "ListTags": { + "methods": [ + "list_tags" + ] + }, + "ListVersions": { + "methods": [ + "list_versions" + ] + }, + "SetIamPolicy": { + "methods": [ + "set_iam_policy" + ] + }, + "TestIamPermissions": { + "methods": [ + "test_iam_permissions" + ] + }, + "UpdateRepository": { + "methods": [ + "update_repository" + ] + }, + "UpdateTag": { + "methods": [ + "update_tag" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/artifactregistry_v1beta2/services/__init__.py b/google/cloud/artifactregistry_v1beta2/services/__init__.py index 42ffdf2..4de6597 100644 --- a/google/cloud/artifactregistry_v1beta2/services/__init__.py +++ b/google/cloud/artifactregistry_v1beta2/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/__init__.py b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/__init__.py index 25e7c98..ddff449 100644 --- a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/__init__.py +++ b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import ArtifactRegistryClient from .async_client import ArtifactRegistryAsyncClient diff --git a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py index 7c3268a..af3a6a7 100644 --- a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py +++ b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore @@ -39,12 +37,11 @@ from google.cloud.artifactregistry_v1beta2.types import tag from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag from google.cloud.artifactregistry_v1beta2.types import version -from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore -from google.iam.v1 import policy_pb2 as policy # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport from .client import ArtifactRegistryClient @@ -75,31 +72,26 @@ class ArtifactRegistryAsyncClient: parse_file_path = staticmethod(ArtifactRegistryClient.parse_file_path) repository_path = staticmethod(ArtifactRegistryClient.repository_path) parse_repository_path = staticmethod(ArtifactRegistryClient.parse_repository_path) - common_billing_account_path = staticmethod( ArtifactRegistryClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( ArtifactRegistryClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(ArtifactRegistryClient.common_folder_path) parse_common_folder_path = staticmethod( ArtifactRegistryClient.parse_common_folder_path ) - common_organization_path = staticmethod( ArtifactRegistryClient.common_organization_path ) parse_common_organization_path = staticmethod( ArtifactRegistryClient.parse_common_organization_path ) - common_project_path = staticmethod(ArtifactRegistryClient.common_project_path) parse_common_project_path = staticmethod( ArtifactRegistryClient.parse_common_project_path ) - common_location_path = staticmethod(ArtifactRegistryClient.common_location_path) parse_common_location_path = staticmethod( ArtifactRegistryClient.parse_common_location_path @@ -107,7 +99,8 @@ class ArtifactRegistryAsyncClient: @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -122,7 +115,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -139,7 +132,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ArtifactRegistryTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: ArtifactRegistryTransport: The transport used by the client instance. @@ -153,12 +146,12 @@ def transport(self) -> ArtifactRegistryTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, ArtifactRegistryTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the artifact registry client. + """Instantiates the artifact registry client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -190,7 +183,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = ArtifactRegistryClient( credentials=credentials, transport=transport, @@ -219,7 +211,6 @@ async def list_repositories( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -249,7 +240,6 @@ async def list_repositories( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -261,7 +251,9 @@ async def list_repositories( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -308,7 +300,6 @@ async def get_repository( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -335,7 +326,6 @@ async def get_repository( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -347,7 +337,9 @@ async def get_repository( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -404,7 +396,6 @@ async def create_repository( This corresponds to the ``repository_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -435,7 +426,6 @@ async def create_repository( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if repository is not None: @@ -476,7 +466,7 @@ async def update_repository( request: gda_repository.UpdateRepositoryRequest = None, *, repository: gda_repository.Repository = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -501,7 +491,6 @@ async def update_repository( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -528,7 +517,6 @@ async def update_repository( # If we have keyword arguments corresponding to fields on the # request, apply these. - if repository is not None: request.repository = repository if update_mask is not None: @@ -578,7 +566,6 @@ async def delete_repository( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -618,7 +605,6 @@ async def delete_repository( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -630,7 +616,9 @@ async def delete_repository( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -650,7 +638,7 @@ async def delete_repository( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=service.OperationMetadata, ) @@ -678,7 +666,6 @@ async def list_packages( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -707,7 +694,6 @@ async def list_packages( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -719,7 +705,9 @@ async def list_packages( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -763,7 +751,6 @@ async def get_package( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -790,7 +777,6 @@ async def get_package( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -802,7 +788,9 @@ async def get_package( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -842,7 +830,6 @@ async def delete_package( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -882,7 +869,6 @@ async def delete_package( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -894,7 +880,9 @@ async def delete_package( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -914,7 +902,7 @@ async def delete_package( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=service.OperationMetadata, ) @@ -942,7 +930,6 @@ async def list_versions( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -971,7 +958,6 @@ async def list_versions( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -983,7 +969,9 @@ async def list_versions( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1027,7 +1015,6 @@ async def get_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1057,7 +1044,6 @@ async def get_version( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1069,7 +1055,9 @@ async def get_version( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1109,7 +1097,6 @@ async def delete_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1149,7 +1136,6 @@ async def delete_version( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1161,7 +1147,9 @@ async def delete_version( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1181,7 +1169,7 @@ async def delete_version( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=service.OperationMetadata, ) @@ -1209,7 +1197,6 @@ async def list_files( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1238,7 +1225,6 @@ async def list_files( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1250,7 +1236,9 @@ async def list_files( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1294,7 +1282,6 @@ async def get_file( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1322,7 +1309,6 @@ async def get_file( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1334,7 +1320,9 @@ async def get_file( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1374,7 +1362,6 @@ async def list_tags( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1403,7 +1390,6 @@ async def list_tags( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1415,7 +1401,9 @@ async def list_tags( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1459,7 +1447,6 @@ async def get_tag( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1487,7 +1474,6 @@ async def get_tag( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1499,7 +1485,9 @@ async def get_tag( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1553,7 +1541,6 @@ async def create_tag( This corresponds to the ``tag_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1581,7 +1568,6 @@ async def create_tag( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tag is not None: @@ -1614,7 +1600,7 @@ async def update_tag( request: gda_tag.UpdateTagRequest = None, *, tag: gda_tag.Tag = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1640,7 +1626,6 @@ async def update_tag( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1668,7 +1653,6 @@ async def update_tag( # If we have keyword arguments corresponding to fields on the # request, apply these. - if tag is not None: request.tag = tag if update_mask is not None: @@ -1713,7 +1697,6 @@ async def delete_tag( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1734,7 +1717,6 @@ async def delete_tag( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1746,7 +1728,9 @@ async def delete_tag( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1766,19 +1750,18 @@ async def delete_tag( async def set_iam_policy( self, - request: iam_policy.SetIamPolicyRequest = None, + request: iam_policy_pb2.SetIamPolicyRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy.Policy: + ) -> policy_pb2.Policy: r"""Updates the IAM policy for a given resource. Args: request (:class:`google.iam.v1.iam_policy_pb2.SetIamPolicyRequest`): The request object. Request message for `SetIamPolicy` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1845,11 +1828,10 @@ async def set_iam_policy( """ # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. if isinstance(request, dict): - request = iam_policy.SetIamPolicyRequest(**request) + request = iam_policy_pb2.SetIamPolicyRequest(**request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1873,19 +1855,18 @@ async def set_iam_policy( async def get_iam_policy( self, - request: iam_policy.GetIamPolicyRequest = None, + request: iam_policy_pb2.GetIamPolicyRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy.Policy: + ) -> policy_pb2.Policy: r"""Gets the IAM policy for a given resource. Args: request (:class:`google.iam.v1.iam_policy_pb2.GetIamPolicyRequest`): The request object. Request message for `GetIamPolicy` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1952,11 +1933,10 @@ async def get_iam_policy( """ # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. if isinstance(request, dict): - request = iam_policy.GetIamPolicyRequest(**request) + request = iam_policy_pb2.GetIamPolicyRequest(**request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1966,7 +1946,9 @@ async def get_iam_policy( initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -1987,12 +1969,12 @@ async def get_iam_policy( async def test_iam_permissions( self, - request: iam_policy.TestIamPermissionsRequest = None, + request: iam_policy_pb2.TestIamPermissionsRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy.TestIamPermissionsResponse: + ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests if the caller has a list of permissions on a resource. @@ -2000,7 +1982,6 @@ async def test_iam_permissions( request (:class:`google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest`): The request object. Request message for `TestIamPermissions` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2012,11 +1993,10 @@ async def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. if isinstance(request, dict): - request = iam_policy.TestIamPermissionsRequest(**request) + request = iam_policy_pb2.TestIamPermissionsRequest(**request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. diff --git a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py index f66b40e..e19b52d 100644 --- a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py +++ b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -43,12 +41,11 @@ from google.cloud.artifactregistry_v1beta2.types import tag from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag from google.cloud.artifactregistry_v1beta2.types import version -from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore -from google.iam.v1 import policy_pb2 as policy # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO from .transports.grpc import ArtifactRegistryGrpcTransport from .transports.grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport @@ -69,7 +66,7 @@ class ArtifactRegistryClientMeta(type): _transport_registry["grpc_asyncio"] = ArtifactRegistryGrpcAsyncIOTransport def get_transport_class(cls, label: str = None,) -> Type[ArtifactRegistryTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -105,7 +102,8 @@ class ArtifactRegistryClient(metaclass=ArtifactRegistryClientMeta): @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS endpoint. + """Converts api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. Args: @@ -139,7 +137,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -156,7 +155,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -175,23 +174,24 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ArtifactRegistryTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - ArtifactRegistryTransport: The transport used by the client instance. + ArtifactRegistryTransport: The transport used by the client + instance. """ return self._transport @staticmethod def file_path(project: str, location: str, repo: str, file: str,) -> str: - """Return a fully-qualified file string.""" + """Returns a fully-qualified file string.""" return "projects/{project}/locations/{location}/repositories/{repo}/files/{file}".format( project=project, location=location, repo=repo, file=file, ) @staticmethod def parse_file_path(path: str) -> Dict[str, str]: - """Parse a file path into its component segments.""" + """Parses a file path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/files/(?P.+?)$", path, @@ -200,14 +200,14 @@ def parse_file_path(path: str) -> Dict[str, str]: @staticmethod def repository_path(project: str, location: str, repository: str,) -> str: - """Return a fully-qualified repository string.""" + """Returns a fully-qualified repository string.""" return "projects/{project}/locations/{location}/repositories/{repository}".format( project=project, location=location, repository=repository, ) @staticmethod def parse_repository_path(path: str) -> Dict[str, str]: - """Parse a repository path into its component segments.""" + """Parses a repository path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)$", path, @@ -216,7 +216,7 @@ def parse_repository_path(path: str) -> Dict[str, str]: @staticmethod def common_billing_account_path(billing_account: str,) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -229,7 +229,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: @staticmethod def common_folder_path(folder: str,) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format(folder=folder,) @staticmethod @@ -240,7 +240,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: @staticmethod def common_organization_path(organization: str,) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format(organization=organization,) @staticmethod @@ -251,7 +251,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: @staticmethod def common_project_path(project: str,) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format(project=project,) @staticmethod @@ -262,7 +262,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]: @staticmethod def common_location_path(project: str, location: str,) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -276,12 +276,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, ArtifactRegistryTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the artifact registry client. + """Instantiates the artifact registry client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -336,9 +336,10 @@ def __init__( client_cert_source_func = client_options.client_cert_source else: is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -350,12 +351,14 @@ def __init__( elif use_mtls_env == "always": api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT else: raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" ) # Save or instantiate the transport. @@ -370,8 +373,8 @@ def __init__( ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: @@ -407,7 +410,6 @@ def list_repositories( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -439,10 +441,8 @@ def list_repositories( # there are no flattened fields. if not isinstance(request, repository.ListRepositoriesRequest): request = repository.ListRepositoriesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -490,7 +490,6 @@ def get_repository( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -519,10 +518,8 @@ def get_repository( # there are no flattened fields. if not isinstance(request, repository.GetRepositoryRequest): request = repository.GetRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -580,7 +577,6 @@ def create_repository( This corresponds to the ``repository_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -613,10 +609,8 @@ def create_repository( # there are no flattened fields. if not isinstance(request, gda_repository.CreateRepositoryRequest): request = gda_repository.CreateRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if repository is not None: @@ -653,7 +647,7 @@ def update_repository( request: gda_repository.UpdateRepositoryRequest = None, *, repository: gda_repository.Repository = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -678,7 +672,6 @@ def update_repository( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -707,10 +700,8 @@ def update_repository( # there are no flattened fields. if not isinstance(request, gda_repository.UpdateRepositoryRequest): request = gda_repository.UpdateRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if repository is not None: request.repository = repository if update_mask is not None: @@ -756,7 +747,6 @@ def delete_repository( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -798,10 +788,8 @@ def delete_repository( # there are no flattened fields. if not isinstance(request, repository.DeleteRepositoryRequest): request = repository.DeleteRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -822,7 +810,7 @@ def delete_repository( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=service.OperationMetadata, ) @@ -850,7 +838,6 @@ def list_packages( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -881,10 +868,8 @@ def list_packages( # there are no flattened fields. if not isinstance(request, package.ListPackagesRequest): request = package.ListPackagesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -929,7 +914,6 @@ def get_package( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -958,10 +942,8 @@ def get_package( # there are no flattened fields. if not isinstance(request, package.GetPackageRequest): request = package.GetPackageRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1002,7 +984,6 @@ def delete_package( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1044,10 +1025,8 @@ def delete_package( # there are no flattened fields. if not isinstance(request, package.DeletePackageRequest): request = package.DeletePackageRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1068,7 +1047,7 @@ def delete_package( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=service.OperationMetadata, ) @@ -1096,7 +1075,6 @@ def list_versions( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1127,10 +1105,8 @@ def list_versions( # there are no flattened fields. if not isinstance(request, version.ListVersionsRequest): request = version.ListVersionsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1175,7 +1151,6 @@ def get_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1207,10 +1182,8 @@ def get_version( # there are no flattened fields. if not isinstance(request, version.GetVersionRequest): request = version.GetVersionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1251,7 +1224,6 @@ def delete_version( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1293,10 +1265,8 @@ def delete_version( # there are no flattened fields. if not isinstance(request, version.DeleteVersionRequest): request = version.DeleteVersionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1317,7 +1287,7 @@ def delete_version( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=service.OperationMetadata, ) @@ -1345,7 +1315,6 @@ def list_files( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1376,10 +1345,8 @@ def list_files( # there are no flattened fields. if not isinstance(request, file.ListFilesRequest): request = file.ListFilesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1424,7 +1391,6 @@ def get_file( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1454,10 +1420,8 @@ def get_file( # there are no flattened fields. if not isinstance(request, file.GetFileRequest): request = file.GetFileRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1498,7 +1462,6 @@ def list_tags( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1529,10 +1492,8 @@ def list_tags( # there are no flattened fields. if not isinstance(request, tag.ListTagsRequest): request = tag.ListTagsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1577,7 +1538,6 @@ def get_tag( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1607,10 +1567,8 @@ def get_tag( # there are no flattened fields. if not isinstance(request, tag.GetTagRequest): request = tag.GetTagRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1665,7 +1623,6 @@ def create_tag( This corresponds to the ``tag_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1695,10 +1652,8 @@ def create_tag( # there are no flattened fields. if not isinstance(request, gda_tag.CreateTagRequest): request = gda_tag.CreateTagRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tag is not None: @@ -1727,7 +1682,7 @@ def update_tag( request: gda_tag.UpdateTagRequest = None, *, tag: gda_tag.Tag = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1753,7 +1708,6 @@ def update_tag( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1783,10 +1737,8 @@ def update_tag( # there are no flattened fields. if not isinstance(request, gda_tag.UpdateTagRequest): request = gda_tag.UpdateTagRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if tag is not None: request.tag = tag if update_mask is not None: @@ -1827,7 +1779,6 @@ def delete_tag( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1850,10 +1801,8 @@ def delete_tag( # there are no flattened fields. if not isinstance(request, tag.DeleteTagRequest): request = tag.DeleteTagRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1874,19 +1823,18 @@ def delete_tag( def set_iam_policy( self, - request: iam_policy.SetIamPolicyRequest = None, + request: iam_policy_pb2.SetIamPolicyRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy.Policy: + ) -> policy_pb2.Policy: r"""Updates the IAM policy for a given resource. Args: request (google.iam.v1.iam_policy_pb2.SetIamPolicyRequest): The request object. Request message for `SetIamPolicy` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1953,14 +1901,13 @@ def set_iam_policy( """ # Create or coerce a protobuf request object. - if isinstance(request, dict): # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. - request = iam_policy.SetIamPolicyRequest(**request) + request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: # Null request, just make one. - request = iam_policy.SetIamPolicyRequest() + request = iam_policy_pb2.SetIamPolicyRequest() # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1980,19 +1927,18 @@ def set_iam_policy( def get_iam_policy( self, - request: iam_policy.GetIamPolicyRequest = None, + request: iam_policy_pb2.GetIamPolicyRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy.Policy: + ) -> policy_pb2.Policy: r"""Gets the IAM policy for a given resource. Args: request (google.iam.v1.iam_policy_pb2.GetIamPolicyRequest): The request object. Request message for `GetIamPolicy` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2059,14 +2005,13 @@ def get_iam_policy( """ # Create or coerce a protobuf request object. - if isinstance(request, dict): # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. - request = iam_policy.GetIamPolicyRequest(**request) + request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: # Null request, just make one. - request = iam_policy.GetIamPolicyRequest() + request = iam_policy_pb2.GetIamPolicyRequest() # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -2086,12 +2031,12 @@ def get_iam_policy( def test_iam_permissions( self, - request: iam_policy.TestIamPermissionsRequest = None, + request: iam_policy_pb2.TestIamPermissionsRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy.TestIamPermissionsResponse: + ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests if the caller has a list of permissions on a resource. @@ -2099,7 +2044,6 @@ def test_iam_permissions( request (google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest): The request object. Request message for `TestIamPermissions` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2111,14 +2055,13 @@ def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - if isinstance(request, dict): # The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. - request = iam_policy.TestIamPermissionsRequest(**request) + request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: # Null request, just make one. - request = iam_policy.TestIamPermissionsRequest() + request = iam_policy_pb2.TestIamPermissionsRequest() # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. diff --git a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py index 9808078..4c1e4d1 100644 --- a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py +++ b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -121,7 +119,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -249,7 +247,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -377,7 +375,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -505,7 +503,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -633,7 +631,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and diff --git a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/__init__.py b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/__init__.py index bb8e489..7e4d6be 100644 --- a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/__init__.py +++ b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/base.py b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/base.py index 9af99f8..1053822 100644 --- a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/base.py +++ b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.artifactregistry_v1beta2.types import file from google.cloud.artifactregistry_v1beta2.types import package @@ -33,11 +33,10 @@ from google.cloud.artifactregistry_v1beta2.types import tag from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag from google.cloud.artifactregistry_v1beta2.types import version -from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore -from google.iam.v1 import policy_pb2 as policy # type: ignore -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -48,6 +47,17 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class ArtifactRegistryTransport(abc.ABC): """Abstract transport class for ArtifactRegistry.""" @@ -57,21 +67,24 @@ class ArtifactRegistryTransport(abc.ABC): "https://www.googleapis.com/auth/cloud-platform.read-only", ) + DEFAULT_HOST: str = "artifactregistry.googleapis.com" + def __init__( self, *, - host: str = "artifactregistry.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -80,7 +93,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -94,29 +107,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -126,7 +186,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -138,7 +200,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -156,7 +220,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -168,7 +234,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -180,7 +248,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -192,7 +262,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -204,7 +276,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -216,7 +290,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -228,7 +304,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -240,7 +318,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -252,7 +332,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -264,7 +346,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -276,7 +360,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -294,7 +380,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -309,7 +397,9 @@ def _prep_wrapped_messages(self, client_info): initial=0.1, maximum=60.0, multiplier=1.3, - predicate=retries.if_exception_type(exceptions.ServiceUnavailable,), + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), deadline=30.0, ), default_timeout=30.0, @@ -330,11 +420,11 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def list_repositories( self, - ) -> typing.Callable[ + ) -> Callable[ [repository.ListRepositoriesRequest], - typing.Union[ + Union[ repository.ListRepositoriesResponse, - typing.Awaitable[repository.ListRepositoriesResponse], + Awaitable[repository.ListRepositoriesResponse], ], ]: raise NotImplementedError() @@ -342,185 +432,171 @@ def list_repositories( @property def get_repository( self, - ) -> typing.Callable[ + ) -> Callable[ [repository.GetRepositoryRequest], - typing.Union[repository.Repository, typing.Awaitable[repository.Repository]], + Union[repository.Repository, Awaitable[repository.Repository]], ]: raise NotImplementedError() @property def create_repository( self, - ) -> typing.Callable[ + ) -> Callable[ [gda_repository.CreateRepositoryRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_repository( self, - ) -> typing.Callable[ + ) -> Callable[ [gda_repository.UpdateRepositoryRequest], - typing.Union[ - gda_repository.Repository, typing.Awaitable[gda_repository.Repository] - ], + Union[gda_repository.Repository, Awaitable[gda_repository.Repository]], ]: raise NotImplementedError() @property def delete_repository( self, - ) -> typing.Callable[ + ) -> Callable[ [repository.DeleteRepositoryRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_packages( self, - ) -> typing.Callable[ + ) -> Callable[ [package.ListPackagesRequest], - typing.Union[ - package.ListPackagesResponse, typing.Awaitable[package.ListPackagesResponse] - ], + Union[package.ListPackagesResponse, Awaitable[package.ListPackagesResponse]], ]: raise NotImplementedError() @property def get_package( self, - ) -> typing.Callable[ - [package.GetPackageRequest], - typing.Union[package.Package, typing.Awaitable[package.Package]], + ) -> Callable[ + [package.GetPackageRequest], Union[package.Package, Awaitable[package.Package]] ]: raise NotImplementedError() @property def delete_package( self, - ) -> typing.Callable[ + ) -> Callable[ [package.DeletePackageRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_versions( self, - ) -> typing.Callable[ + ) -> Callable[ [version.ListVersionsRequest], - typing.Union[ - version.ListVersionsResponse, typing.Awaitable[version.ListVersionsResponse] - ], + Union[version.ListVersionsResponse, Awaitable[version.ListVersionsResponse]], ]: raise NotImplementedError() @property def get_version( self, - ) -> typing.Callable[ - [version.GetVersionRequest], - typing.Union[version.Version, typing.Awaitable[version.Version]], + ) -> Callable[ + [version.GetVersionRequest], Union[version.Version, Awaitable[version.Version]] ]: raise NotImplementedError() @property def delete_version( self, - ) -> typing.Callable[ + ) -> Callable[ [version.DeleteVersionRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_files( self, - ) -> typing.Callable[ + ) -> Callable[ [file.ListFilesRequest], - typing.Union[file.ListFilesResponse, typing.Awaitable[file.ListFilesResponse]], + Union[file.ListFilesResponse, Awaitable[file.ListFilesResponse]], ]: raise NotImplementedError() @property def get_file( self, - ) -> typing.Callable[ - [file.GetFileRequest], typing.Union[file.File, typing.Awaitable[file.File]] - ]: + ) -> Callable[[file.GetFileRequest], Union[file.File, Awaitable[file.File]]]: raise NotImplementedError() @property def list_tags( self, - ) -> typing.Callable[ + ) -> Callable[ [tag.ListTagsRequest], - typing.Union[tag.ListTagsResponse, typing.Awaitable[tag.ListTagsResponse]], + Union[tag.ListTagsResponse, Awaitable[tag.ListTagsResponse]], ]: raise NotImplementedError() @property def get_tag( self, - ) -> typing.Callable[ - [tag.GetTagRequest], typing.Union[tag.Tag, typing.Awaitable[tag.Tag]] - ]: + ) -> Callable[[tag.GetTagRequest], Union[tag.Tag, Awaitable[tag.Tag]]]: raise NotImplementedError() @property def create_tag( self, - ) -> typing.Callable[ - [gda_tag.CreateTagRequest], - typing.Union[gda_tag.Tag, typing.Awaitable[gda_tag.Tag]], + ) -> Callable[ + [gda_tag.CreateTagRequest], Union[gda_tag.Tag, Awaitable[gda_tag.Tag]] ]: raise NotImplementedError() @property def update_tag( self, - ) -> typing.Callable[ - [gda_tag.UpdateTagRequest], - typing.Union[gda_tag.Tag, typing.Awaitable[gda_tag.Tag]], + ) -> Callable[ + [gda_tag.UpdateTagRequest], Union[gda_tag.Tag, Awaitable[gda_tag.Tag]] ]: raise NotImplementedError() @property def delete_tag( self, - ) -> typing.Callable[ - [tag.DeleteTagRequest], typing.Union[empty.Empty, typing.Awaitable[empty.Empty]] + ) -> Callable[ + [tag.DeleteTagRequest], Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]] ]: raise NotImplementedError() @property def set_iam_policy( self, - ) -> typing.Callable[ - [iam_policy.SetIamPolicyRequest], - typing.Union[policy.Policy, typing.Awaitable[policy.Policy]], + ) -> Callable[ + [iam_policy_pb2.SetIamPolicyRequest], + Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError() @property def get_iam_policy( self, - ) -> typing.Callable[ - [iam_policy.GetIamPolicyRequest], - typing.Union[policy.Policy, typing.Awaitable[policy.Policy]], + ) -> Callable[ + [iam_policy_pb2.GetIamPolicyRequest], + Union[policy_pb2.Policy, Awaitable[policy_pb2.Policy]], ]: raise NotImplementedError() @property def test_iam_permissions( self, - ) -> typing.Callable[ - [iam_policy.TestIamPermissionsRequest], - typing.Union[ - iam_policy.TestIamPermissionsResponse, - typing.Awaitable[iam_policy.TestIamPermissionsResponse], + ) -> Callable[ + [iam_policy_pb2.TestIamPermissionsRequest], + Union[ + iam_policy_pb2.TestIamPermissionsResponse, + Awaitable[iam_policy_pb2.TestIamPermissionsResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py index 4db68b4..2746e25 100644 --- a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py +++ b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -34,11 +32,10 @@ from google.cloud.artifactregistry_v1beta2.types import tag from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag from google.cloud.artifactregistry_v1beta2.types import version -from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore -from google.iam.v1 import policy_pb2 as policy # type: ignore -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO @@ -73,7 +70,7 @@ def __init__( self, *, host: str = "artifactregistry.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -87,7 +84,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -198,7 +196,7 @@ def __init__( def create_channel( cls, host: str = "artifactregistry.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -229,13 +227,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -316,7 +316,7 @@ def get_repository( @property def create_repository( self, - ) -> Callable[[gda_repository.CreateRepositoryRequest], operations.Operation]: + ) -> Callable[[gda_repository.CreateRepositoryRequest], operations_pb2.Operation]: r"""Return a callable for the create repository method over gRPC. Creates a repository. The returned Operation will @@ -337,7 +337,7 @@ def create_repository( self._stubs["create_repository"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateRepository", request_serializer=gda_repository.CreateRepositoryRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_repository"] @@ -370,7 +370,7 @@ def update_repository( @property def delete_repository( self, - ) -> Callable[[repository.DeleteRepositoryRequest], operations.Operation]: + ) -> Callable[[repository.DeleteRepositoryRequest], operations_pb2.Operation]: r"""Return a callable for the delete repository method over gRPC. Deletes a repository and all of its contents. The @@ -392,7 +392,7 @@ def delete_repository( self._stubs["delete_repository"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteRepository", request_serializer=repository.DeleteRepositoryRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_repository"] @@ -449,7 +449,7 @@ def get_package(self) -> Callable[[package.GetPackageRequest], package.Package]: @property def delete_package( self, - ) -> Callable[[package.DeletePackageRequest], operations.Operation]: + ) -> Callable[[package.DeletePackageRequest], operations_pb2.Operation]: r"""Return a callable for the delete package method over gRPC. Deletes a package and all of its versions and tags. @@ -470,7 +470,7 @@ def delete_package( self._stubs["delete_package"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeletePackage", request_serializer=package.DeletePackageRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_package"] @@ -527,7 +527,7 @@ def get_version(self) -> Callable[[version.GetVersionRequest], version.Version]: @property def delete_version( self, - ) -> Callable[[version.DeleteVersionRequest], operations.Operation]: + ) -> Callable[[version.DeleteVersionRequest], operations_pb2.Operation]: r"""Return a callable for the delete version method over gRPC. Deletes a version and all of its content. The @@ -548,7 +548,7 @@ def delete_version( self._stubs["delete_version"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_version"] @@ -697,7 +697,7 @@ def update_tag(self) -> Callable[[gda_tag.UpdateTagRequest], gda_tag.Tag]: return self._stubs["update_tag"] @property - def delete_tag(self) -> Callable[[tag.DeleteTagRequest], empty.Empty]: + def delete_tag(self) -> Callable[[tag.DeleteTagRequest], empty_pb2.Empty]: r"""Return a callable for the delete tag method over gRPC. Deletes a tag. @@ -716,14 +716,14 @@ def delete_tag(self) -> Callable[[tag.DeleteTagRequest], empty.Empty]: self._stubs["delete_tag"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteTag", request_serializer=tag.DeleteTagRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_tag"] @property def set_iam_policy( self, - ) -> Callable[[iam_policy.SetIamPolicyRequest], policy.Policy]: + ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the set iam policy method over gRPC. Updates the IAM policy for a given resource. @@ -741,15 +741,15 @@ def set_iam_policy( if "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/SetIamPolicy", - request_serializer=iam_policy.SetIamPolicyRequest.SerializeToString, - response_deserializer=policy.Policy.FromString, + request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, + response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"] @property def get_iam_policy( self, - ) -> Callable[[iam_policy.GetIamPolicyRequest], policy.Policy]: + ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM policy for a given resource. @@ -767,8 +767,8 @@ def get_iam_policy( if "get_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetIamPolicy", - request_serializer=iam_policy.GetIamPolicyRequest.SerializeToString, - response_deserializer=policy.Policy.FromString, + request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, + response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"] @@ -776,7 +776,8 @@ def get_iam_policy( def test_iam_permissions( self, ) -> Callable[ - [iam_policy.TestIamPermissionsRequest], iam_policy.TestIamPermissionsResponse + [iam_policy_pb2.TestIamPermissionsRequest], + iam_policy_pb2.TestIamPermissionsResponse, ]: r"""Return a callable for the test iam permissions method over gRPC. @@ -796,8 +797,8 @@ def test_iam_permissions( if "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/TestIamPermissions", - request_serializer=iam_policy.TestIamPermissionsRequest.SerializeToString, - response_deserializer=iam_policy.TestIamPermissionsResponse.FromString, + request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, + response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"] diff --git a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py index 290f4f6..00687fa 100644 --- a/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py +++ b/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -35,11 +33,10 @@ from google.cloud.artifactregistry_v1beta2.types import tag from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag from google.cloud.artifactregistry_v1beta2.types import version -from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore -from google.iam.v1 import policy_pb2 as policy # type: ignore -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO from .grpc import ArtifactRegistryGrpcTransport @@ -76,7 +73,7 @@ class ArtifactRegistryGrpcAsyncIOTransport(ArtifactRegistryTransport): def create_channel( cls, host: str = "artifactregistry.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -103,13 +100,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -117,7 +116,7 @@ def __init__( self, *, host: str = "artifactregistry.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -131,7 +130,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -190,7 +190,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -324,7 +323,7 @@ def get_repository( def create_repository( self, ) -> Callable[ - [gda_repository.CreateRepositoryRequest], Awaitable[operations.Operation] + [gda_repository.CreateRepositoryRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create repository method over gRPC. @@ -346,7 +345,7 @@ def create_repository( self._stubs["create_repository"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateRepository", request_serializer=gda_repository.CreateRepositoryRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_repository"] @@ -382,7 +381,7 @@ def update_repository( def delete_repository( self, ) -> Callable[ - [repository.DeleteRepositoryRequest], Awaitable[operations.Operation] + [repository.DeleteRepositoryRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete repository method over gRPC. @@ -405,7 +404,7 @@ def delete_repository( self._stubs["delete_repository"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteRepository", request_serializer=repository.DeleteRepositoryRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_repository"] @@ -466,7 +465,7 @@ def get_package( @property def delete_package( self, - ) -> Callable[[package.DeletePackageRequest], Awaitable[operations.Operation]]: + ) -> Callable[[package.DeletePackageRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the delete package method over gRPC. Deletes a package and all of its versions and tags. @@ -487,7 +486,7 @@ def delete_package( self._stubs["delete_package"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeletePackage", request_serializer=package.DeletePackageRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_package"] @@ -548,7 +547,7 @@ def get_version( @property def delete_version( self, - ) -> Callable[[version.DeleteVersionRequest], Awaitable[operations.Operation]]: + ) -> Callable[[version.DeleteVersionRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the delete version method over gRPC. Deletes a version and all of its content. The @@ -569,7 +568,7 @@ def delete_version( self._stubs["delete_version"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_version"] @@ -726,7 +725,9 @@ def update_tag( return self._stubs["update_tag"] @property - def delete_tag(self) -> Callable[[tag.DeleteTagRequest], Awaitable[empty.Empty]]: + def delete_tag( + self, + ) -> Callable[[tag.DeleteTagRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete tag method over gRPC. Deletes a tag. @@ -745,14 +746,14 @@ def delete_tag(self) -> Callable[[tag.DeleteTagRequest], Awaitable[empty.Empty]] self._stubs["delete_tag"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteTag", request_serializer=tag.DeleteTagRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_tag"] @property def set_iam_policy( self, - ) -> Callable[[iam_policy.SetIamPolicyRequest], Awaitable[policy.Policy]]: + ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], Awaitable[policy_pb2.Policy]]: r"""Return a callable for the set iam policy method over gRPC. Updates the IAM policy for a given resource. @@ -770,15 +771,15 @@ def set_iam_policy( if "set_iam_policy" not in self._stubs: self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/SetIamPolicy", - request_serializer=iam_policy.SetIamPolicyRequest.SerializeToString, - response_deserializer=policy.Policy.FromString, + request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, + response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["set_iam_policy"] @property def get_iam_policy( self, - ) -> Callable[[iam_policy.GetIamPolicyRequest], Awaitable[policy.Policy]]: + ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], Awaitable[policy_pb2.Policy]]: r"""Return a callable for the get iam policy method over gRPC. Gets the IAM policy for a given resource. @@ -796,8 +797,8 @@ def get_iam_policy( if "get_iam_policy" not in self._stubs: self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetIamPolicy", - request_serializer=iam_policy.GetIamPolicyRequest.SerializeToString, - response_deserializer=policy.Policy.FromString, + request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, + response_deserializer=policy_pb2.Policy.FromString, ) return self._stubs["get_iam_policy"] @@ -805,8 +806,8 @@ def get_iam_policy( def test_iam_permissions( self, ) -> Callable[ - [iam_policy.TestIamPermissionsRequest], - Awaitable[iam_policy.TestIamPermissionsResponse], + [iam_policy_pb2.TestIamPermissionsRequest], + Awaitable[iam_policy_pb2.TestIamPermissionsResponse], ]: r"""Return a callable for the test iam permissions method over gRPC. @@ -826,8 +827,8 @@ def test_iam_permissions( if "test_iam_permissions" not in self._stubs: self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/TestIamPermissions", - request_serializer=iam_policy.TestIamPermissionsRequest.SerializeToString, - response_deserializer=iam_policy.TestIamPermissionsResponse.FromString, + request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, + response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, ) return self._stubs["test_iam_permissions"] diff --git a/google/cloud/artifactregistry_v1beta2/types/__init__.py b/google/cloud/artifactregistry_v1beta2/types/__init__.py index 22959e3..9664fcb 100644 --- a/google/cloud/artifactregistry_v1beta2/types/__init__.py +++ b/google/cloud/artifactregistry_v1beta2/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .file import ( File, GetFileRequest, diff --git a/google/cloud/artifactregistry_v1beta2/types/file.py b/google/cloud/artifactregistry_v1beta2/types/file.py index 6e6cbbe..0976132 100644 --- a/google/cloud/artifactregistry_v1beta2/types/file.py +++ b/google/cloud/artifactregistry_v1beta2/types/file.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -49,8 +46,7 @@ class HashType(proto.Enum): SHA256 = 1 type_ = proto.Field(proto.ENUM, number=1, enum=HashType,) - - value = proto.Field(proto.BYTES, number=2) + value = proto.Field(proto.BYTES, number=2,) class File(proto.Message): @@ -75,17 +71,12 @@ class File(proto.Message): this file, if any. """ - name = proto.Field(proto.STRING, number=1) - - size_bytes = proto.Field(proto.INT64, number=3) - + name = proto.Field(proto.STRING, number=1,) + size_bytes = proto.Field(proto.INT64, number=3,) hashes = proto.RepeatedField(proto.MESSAGE, number=4, message="Hash",) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - owner = proto.Field(proto.STRING, number=7) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + owner = proto.Field(proto.STRING, number=7,) class ListFilesRequest(proto.Message): @@ -117,13 +108,10 @@ class ListFilesRequest(proto.Message): request, if any. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=4) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=4,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListFilesResponse(proto.Message): @@ -142,8 +130,7 @@ def raw_page(self): return self files = proto.RepeatedField(proto.MESSAGE, number=1, message="File",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetFileRequest(proto.Message): @@ -154,7 +141,7 @@ class GetFileRequest(proto.Message): The name of the file to retrieve. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/artifactregistry_v1beta2/types/package.py b/google/cloud/artifactregistry_v1beta2/types/package.py index 5ebf8f6..6a89202 100644 --- a/google/cloud/artifactregistry_v1beta2/types/package.py +++ b/google/cloud/artifactregistry_v1beta2/types/package.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -35,7 +32,6 @@ class Package(proto.Message): r"""Packages are named collections of versions. - Attributes: name (str): The name of the package, for example: @@ -51,18 +47,14 @@ class Package(proto.Message): package. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) class ListPackagesRequest(proto.Message): r"""The request to list packages. - Attributes: parent (str): The name of the parent resource whose @@ -75,16 +67,13 @@ class ListPackagesRequest(proto.Message): request, if any. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListPackagesResponse(proto.Message): r"""The response from listing packages. - Attributes: packages (Sequence[google.cloud.artifactregistry_v1beta2.types.Package]): The packages returned. @@ -99,30 +88,27 @@ def raw_page(self): return self packages = proto.RepeatedField(proto.MESSAGE, number=1, message="Package",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetPackageRequest(proto.Message): r"""The request to retrieve a package. - Attributes: name (str): The name of the package to retrieve. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeletePackageRequest(proto.Message): r"""The request to delete a package. - Attributes: name (str): The name of the package to delete. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/artifactregistry_v1beta2/types/repository.py b/google/cloud/artifactregistry_v1beta2/types/repository.py index e2a9ba9..ce69609 100644 --- a/google/cloud/artifactregistry_v1beta2/types/repository.py +++ b/google/cloud/artifactregistry_v1beta2/types/repository.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -38,7 +35,6 @@ class Repository(proto.Message): r"""A Repository for storing artifacts with a specific format. - Attributes: name (str): The name of the repository, for example: @@ -77,24 +73,17 @@ class Format(proto.Enum): FORMAT_UNSPECIFIED = 0 DOCKER = 1 - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) format_ = proto.Field(proto.ENUM, number=2, enum=Format,) - - description = proto.Field(proto.STRING, number=3) - - labels = proto.MapField(proto.STRING, proto.STRING, number=4) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - kms_key_name = proto.Field(proto.STRING, number=8) + description = proto.Field(proto.STRING, number=3,) + labels = proto.MapField(proto.STRING, proto.STRING, number=4,) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + kms_key_name = proto.Field(proto.STRING, number=8,) class ListRepositoriesRequest(proto.Message): r"""The request to list repositories. - Attributes: parent (str): The name of the parent resource whose @@ -107,16 +96,13 @@ class ListRepositoriesRequest(proto.Message): request, if any. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListRepositoriesResponse(proto.Message): r"""The response from listing repositories. - Attributes: repositories (Sequence[google.cloud.artifactregistry_v1beta2.types.Repository]): The repositories returned. @@ -131,24 +117,21 @@ def raw_page(self): return self repositories = proto.RepeatedField(proto.MESSAGE, number=1, message="Repository",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetRepositoryRequest(proto.Message): r"""The request to retrieve a repository. - Attributes: name (str): The name of the repository to retrieve. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateRepositoryRequest(proto.Message): r"""The request to create a new repository. - Attributes: parent (str): The name of the parent resource where the @@ -159,16 +142,13 @@ class CreateRepositoryRequest(proto.Message): The repository to be created. """ - parent = proto.Field(proto.STRING, number=1) - - repository_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + repository_id = proto.Field(proto.STRING, number=2,) repository = proto.Field(proto.MESSAGE, number=3, message="Repository",) class UpdateRepositoryRequest(proto.Message): r"""The request to update a repository. - Attributes: repository (google.cloud.artifactregistry_v1beta2.types.Repository): The repository that replaces the resource on @@ -180,19 +160,19 @@ class UpdateRepositoryRequest(proto.Message): """ repository = proto.Field(proto.MESSAGE, number=1, message="Repository",) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteRepositoryRequest(proto.Message): r"""The request to delete a repository. - Attributes: name (str): The name of the repository to delete. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/artifactregistry_v1beta2/types/service.py b/google/cloud/artifactregistry_v1beta2/types/service.py index b335efe..439dc9c 100644 --- a/google/cloud/artifactregistry_v1beta2/types/service.py +++ b/google/cloud/artifactregistry_v1beta2/types/service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -24,7 +22,7 @@ class OperationMetadata(proto.Message): - r"""Metadata type for longrunning-operations, currently empty.""" + r"""Metadata type for longrunning-operations, currently empty. """ __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/artifactregistry_v1beta2/types/settings.py b/google/cloud/artifactregistry_v1beta2/types/settings.py index a7f64ff..646a060 100644 --- a/google/cloud/artifactregistry_v1beta2/types/settings.py +++ b/google/cloud/artifactregistry_v1beta2/types/settings.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/artifactregistry_v1beta2/types/tag.py b/google/cloud/artifactregistry_v1beta2/types/tag.py index 414254a..a3a08af 100644 --- a/google/cloud/artifactregistry_v1beta2/types/tag.py +++ b/google/cloud/artifactregistry_v1beta2/types/tag.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -50,14 +47,12 @@ class Tag(proto.Message): central1/repositories/repo1/packages/pkg1/versions/sha256:5243811". """ - name = proto.Field(proto.STRING, number=1) - - version = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + version = proto.Field(proto.STRING, number=2,) class ListTagsRequest(proto.Message): r"""The request to list tags. - Attributes: parent (str): The name of the parent resource whose tags @@ -82,18 +77,14 @@ class ListTagsRequest(proto.Message): request, if any. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=4) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=4,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListTagsResponse(proto.Message): r"""The response from listing tags. - Attributes: tags (Sequence[google.cloud.artifactregistry_v1beta2.types.Tag]): The tags returned. @@ -107,24 +98,21 @@ def raw_page(self): return self tags = proto.RepeatedField(proto.MESSAGE, number=1, message="Tag",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetTagRequest(proto.Message): r"""The request to retrieve a tag. - Attributes: name (str): The name of the tag to retrieve. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateTagRequest(proto.Message): r"""The request to create a new tag. - Attributes: parent (str): The name of the parent resource where the tag @@ -135,16 +123,13 @@ class CreateTagRequest(proto.Message): The tag to be created. """ - parent = proto.Field(proto.STRING, number=1) - - tag_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + tag_id = proto.Field(proto.STRING, number=2,) tag = proto.Field(proto.MESSAGE, number=3, message="Tag",) class UpdateTagRequest(proto.Message): r"""The request to create or update a tag. - Attributes: tag (google.cloud.artifactregistry_v1beta2.types.Tag): The tag that replaces the resource on the @@ -156,19 +141,19 @@ class UpdateTagRequest(proto.Message): """ tag = proto.Field(proto.MESSAGE, number=1, message="Tag",) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteTagRequest(proto.Message): r"""The request to delete a tag. - Attributes: name (str): The name of the tag to delete. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/artifactregistry_v1beta2/types/version.py b/google/cloud/artifactregistry_v1beta2/types/version.py index e07f0f0..791c101 100644 --- a/google/cloud/artifactregistry_v1beta2/types/version.py +++ b/google/cloud/artifactregistry_v1beta2/types/version.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.artifactregistry_v1beta2.types import tag -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -67,20 +64,15 @@ class Version(proto.Message): version. """ - name = proto.Field(proto.STRING, number=1) - - description = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - + name = proto.Field(proto.STRING, number=1,) + description = proto.Field(proto.STRING, number=3,) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) related_tags = proto.RepeatedField(proto.MESSAGE, number=7, message=tag.Tag,) class ListVersionsRequest(proto.Message): r"""The request to list versions. - Attributes: parent (str): The name of the parent resource whose @@ -96,18 +88,14 @@ class ListVersionsRequest(proto.Message): response. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) view = proto.Field(proto.ENUM, number=4, enum="VersionView",) class ListVersionsResponse(proto.Message): r"""The response from listing versions. - Attributes: versions (Sequence[google.cloud.artifactregistry_v1beta2.types.Version]): The versions returned. @@ -122,13 +110,11 @@ def raw_page(self): return self versions = proto.RepeatedField(proto.MESSAGE, number=1, message="Version",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetVersionRequest(proto.Message): r"""The request to retrieve a version. - Attributes: name (str): The name of the version to retrieve. @@ -137,14 +123,12 @@ class GetVersionRequest(proto.Message): response. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) view = proto.Field(proto.ENUM, number=2, enum="VersionView",) class DeleteVersionRequest(proto.Message): r"""The request to delete a version. - Attributes: name (str): The name of the version to delete. @@ -154,9 +138,8 @@ class DeleteVersionRequest(proto.Message): tags pointing to the version are deleted. """ - name = proto.Field(proto.STRING, number=1) - - force = proto.Field(proto.BOOL, number=2) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owlbot.py b/owlbot.py index a68ac87..147dfe2 100644 --- a/owlbot.py +++ b/owlbot.py @@ -25,6 +25,14 @@ default_version = "v1beta2" for library in s.get_staging_dirs(default_version): + # Work around gapic generator bug https://github.com/googleapis/gapic-generator-python/issues/902 + s.replace(library / f"google/cloud/artifactregistry_{library.name}/types/file.py", + r""". + Attributes:""", + r""".\n + Attributes:""", + ) + s.move(library, excludes=["nox.py", "setup.py", "README.rst", "docs/index.rst"]) s.remove_staging_dirs() diff --git a/scripts/fixup_artifactregistry_v1beta2_keywords.py b/scripts/fixup_artifactregistry_v1beta2_keywords.py index 69ca108..a275fa0 100644 --- a/scripts/fixup_artifactregistry_v1beta2_keywords.py +++ b/scripts/fixup_artifactregistry_v1beta2_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,28 +39,27 @@ def partition( class artifactregistryCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_repository': ('parent', 'repository_id', 'repository', ), - 'create_tag': ('parent', 'tag_id', 'tag', ), - 'delete_package': ('name', ), - 'delete_repository': ('name', ), - 'delete_tag': ('name', ), - 'delete_version': ('name', 'force', ), - 'get_file': ('name', ), - 'get_iam_policy': ('resource', 'options', ), - 'get_package': ('name', ), - 'get_repository': ('name', ), - 'get_tag': ('name', ), - 'get_version': ('name', 'view', ), - 'list_files': ('parent', 'filter', 'page_size', 'page_token', ), - 'list_packages': ('parent', 'page_size', 'page_token', ), - 'list_repositories': ('parent', 'page_size', 'page_token', ), - 'list_tags': ('parent', 'filter', 'page_size', 'page_token', ), - 'list_versions': ('parent', 'page_size', 'page_token', 'view', ), - 'set_iam_policy': ('resource', 'policy', ), - 'test_iam_permissions': ('resource', 'permissions', ), - 'update_repository': ('repository', 'update_mask', ), - 'update_tag': ('tag', 'update_mask', ), - + 'create_repository': ('parent', 'repository_id', 'repository', ), + 'create_tag': ('parent', 'tag_id', 'tag', ), + 'delete_package': ('name', ), + 'delete_repository': ('name', ), + 'delete_tag': ('name', ), + 'delete_version': ('name', 'force', ), + 'get_file': ('name', ), + 'get_iam_policy': ('resource', 'options', ), + 'get_package': ('name', ), + 'get_repository': ('name', ), + 'get_tag': ('name', ), + 'get_version': ('name', 'view', ), + 'list_files': ('parent', 'filter', 'page_size', 'page_token', ), + 'list_packages': ('parent', 'page_size', 'page_token', ), + 'list_repositories': ('parent', 'page_size', 'page_token', ), + 'list_tags': ('parent', 'filter', 'page_size', 'page_token', ), + 'list_versions': ('parent', 'page_size', 'page_token', 'view', ), + 'set_iam_policy': ('resource', 'policy', ), + 'test_iam_permissions': ('resource', 'permissions', ), + 'update_repository': ('repository', 'update_mask', ), + 'update_tag': ('tag', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -93,7 +90,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +cst.Element(value=arg.value) ) # Note: the args + kwargs looks silly, but keep in mind that # the control parameters had to be stripped out, and that diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/gapic/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/artifactregistry_v1beta2/__init__.py b/tests/unit/gapic/artifactregistry_v1beta2/__init__.py index 42ffdf2..4de6597 100644 --- a/tests/unit/gapic/artifactregistry_v1beta2/__init__.py +++ b/tests/unit/gapic/artifactregistry_v1beta2/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py b/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py index 11d60a6..6871344 100644 --- a/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py +++ b/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.artifactregistry_v1beta2.services.artifact_registry import ( ArtifactRegistryAsyncClient, @@ -43,6 +42,12 @@ ) from google.cloud.artifactregistry_v1beta2.services.artifact_registry import pagers from google.cloud.artifactregistry_v1beta2.services.artifact_registry import transports +from google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.artifactregistry_v1beta2.types import file from google.cloud.artifactregistry_v1beta2.types import package from google.cloud.artifactregistry_v1beta2.types import repository @@ -51,14 +56,38 @@ from google.cloud.artifactregistry_v1beta2.types import tag from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag from google.cloud.artifactregistry_v1beta2.types import version -from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore -from google.iam.v1 import options_pb2 as options # type: ignore -from google.iam.v1 import policy_pb2 as policy # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import options_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import expr_pb2 as expr # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -110,7 +139,7 @@ def test__get_default_mtls_endpoint(): "client_class", [ArtifactRegistryClient, ArtifactRegistryAsyncClient,] ) def test_artifact_registry_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -127,7 +156,7 @@ def test_artifact_registry_client_from_service_account_info(client_class): "client_class", [ArtifactRegistryClient, ArtifactRegistryAsyncClient,] ) def test_artifact_registry_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -180,7 +209,7 @@ def test_artifact_registry_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(ArtifactRegistryClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -478,7 +507,7 @@ def test_list_repositories( transport: str = "grpc", request_type=repository.ListRepositoriesRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -493,19 +522,15 @@ def test_list_repositories( call.return_value = repository.ListRepositoriesResponse( next_page_token="next_page_token_value", ) - response = client.list_repositories(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == repository.ListRepositoriesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRepositoriesPager) - assert response.next_page_token == "next_page_token_value" @@ -517,7 +542,7 @@ def test_list_repositories_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -527,7 +552,6 @@ def test_list_repositories_empty_call(): client.list_repositories() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == repository.ListRepositoriesRequest() @@ -536,7 +560,7 @@ async def test_list_repositories_async( transport: str = "grpc_asyncio", request_type=repository.ListRepositoriesRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -553,18 +577,15 @@ async def test_list_repositories_async( next_page_token="next_page_token_value", ) ) - response = await client.list_repositories(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == repository.ListRepositoriesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListRepositoriesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -574,11 +595,12 @@ async def test_list_repositories_async_from_dict(): def test_list_repositories_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = repository.ListRepositoriesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -586,7 +608,6 @@ def test_list_repositories_field_headers(): type(client.transport.list_repositories), "__call__" ) as call: call.return_value = repository.ListRepositoriesResponse() - client.list_repositories(request) # Establish that the underlying gRPC stub method was called. @@ -602,12 +623,13 @@ def test_list_repositories_field_headers(): @pytest.mark.asyncio async def test_list_repositories_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = repository.ListRepositoriesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -617,7 +639,6 @@ async def test_list_repositories_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( repository.ListRepositoriesResponse() ) - await client.list_repositories(request) # Establish that the underlying gRPC stub method was called. @@ -631,7 +652,7 @@ async def test_list_repositories_field_headers_async(): def test_list_repositories_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -639,7 +660,6 @@ def test_list_repositories_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = repository.ListRepositoriesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_repositories(parent="parent_value",) @@ -648,12 +668,11 @@ def test_list_repositories_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_repositories_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -666,7 +685,7 @@ def test_list_repositories_flattened_error(): @pytest.mark.asyncio async def test_list_repositories_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -687,14 +706,13 @@ async def test_list_repositories_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_repositories_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -706,7 +724,7 @@ async def test_list_repositories_flattened_error_async(): def test_list_repositories_pager(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -748,7 +766,7 @@ def test_list_repositories_pager(): def test_list_repositories_pages(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -782,7 +800,9 @@ def test_list_repositories_pages(): @pytest.mark.asyncio async def test_list_repositories_async_pager(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -823,7 +843,9 @@ async def test_list_repositories_async_pager(): @pytest.mark.asyncio async def test_list_repositories_async_pages(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -863,7 +885,7 @@ def test_get_repository( transport: str = "grpc", request_type=repository.GetRepositoryRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -879,25 +901,18 @@ def test_get_repository( description="description_value", kms_key_name="kms_key_name_value", ) - response = client.get_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == repository.GetRepositoryRequest() # Establish that the response is the type that we expect. - assert isinstance(response, repository.Repository) - assert response.name == "name_value" - assert response.format_ == repository.Repository.Format.DOCKER - assert response.description == "description_value" - assert response.kms_key_name == "kms_key_name_value" @@ -909,7 +924,7 @@ def test_get_repository_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -917,7 +932,6 @@ def test_get_repository_empty_call(): client.get_repository() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == repository.GetRepositoryRequest() @@ -926,7 +940,7 @@ async def test_get_repository_async( transport: str = "grpc_asyncio", request_type=repository.GetRepositoryRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -944,24 +958,18 @@ async def test_get_repository_async( kms_key_name="kms_key_name_value", ) ) - response = await client.get_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == repository.GetRepositoryRequest() # Establish that the response is the type that we expect. assert isinstance(response, repository.Repository) - assert response.name == "name_value" - assert response.format_ == repository.Repository.Format.DOCKER - assert response.description == "description_value" - assert response.kms_key_name == "kms_key_name_value" @@ -971,17 +979,17 @@ async def test_get_repository_async_from_dict(): def test_get_repository_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = repository.GetRepositoryRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_repository), "__call__") as call: call.return_value = repository.Repository() - client.get_repository(request) # Establish that the underlying gRPC stub method was called. @@ -997,12 +1005,13 @@ def test_get_repository_field_headers(): @pytest.mark.asyncio async def test_get_repository_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = repository.GetRepositoryRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1010,7 +1019,6 @@ async def test_get_repository_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( repository.Repository() ) - await client.get_repository(request) # Establish that the underlying gRPC stub method was called. @@ -1024,13 +1032,12 @@ async def test_get_repository_field_headers_async(): def test_get_repository_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_repository), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = repository.Repository() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_repository(name="name_value",) @@ -1039,12 +1046,11 @@ def test_get_repository_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_repository_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1057,7 +1063,7 @@ def test_get_repository_flattened_error(): @pytest.mark.asyncio async def test_get_repository_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1076,14 +1082,13 @@ async def test_get_repository_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_repository_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1098,7 +1103,7 @@ def test_create_repository( transport: str = "grpc", request_type=gda_repository.CreateRepositoryRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1111,13 +1116,11 @@ def test_create_repository( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.CreateRepositoryRequest() # Establish that the response is the type that we expect. @@ -1132,7 +1135,7 @@ def test_create_repository_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1142,7 +1145,6 @@ def test_create_repository_empty_call(): client.create_repository() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.CreateRepositoryRequest() @@ -1151,7 +1153,7 @@ async def test_create_repository_async( transport: str = "grpc_asyncio", request_type=gda_repository.CreateRepositoryRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1166,13 +1168,11 @@ async def test_create_repository_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.CreateRepositoryRequest() # Establish that the response is the type that we expect. @@ -1185,11 +1185,12 @@ async def test_create_repository_async_from_dict(): def test_create_repository_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = gda_repository.CreateRepositoryRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1197,7 +1198,6 @@ def test_create_repository_field_headers(): type(client.transport.create_repository), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_repository(request) # Establish that the underlying gRPC stub method was called. @@ -1213,12 +1213,13 @@ def test_create_repository_field_headers(): @pytest.mark.asyncio async def test_create_repository_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = gda_repository.CreateRepositoryRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1228,7 +1229,6 @@ async def test_create_repository_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_repository(request) # Establish that the underlying gRPC stub method was called. @@ -1242,7 +1242,7 @@ async def test_create_repository_field_headers_async(): def test_create_repository_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1250,7 +1250,6 @@ def test_create_repository_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_repository( @@ -1263,16 +1262,13 @@ def test_create_repository_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].repository == gda_repository.Repository(name="name_value") - assert args[0].repository_id == "repository_id_value" def test_create_repository_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1288,7 +1284,7 @@ def test_create_repository_flattened_error(): @pytest.mark.asyncio async def test_create_repository_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1313,18 +1309,15 @@ async def test_create_repository_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].repository == gda_repository.Repository(name="name_value") - assert args[0].repository_id == "repository_id_value" @pytest.mark.asyncio async def test_create_repository_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1342,7 +1335,7 @@ def test_update_repository( transport: str = "grpc", request_type=gda_repository.UpdateRepositoryRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1360,25 +1353,18 @@ def test_update_repository( description="description_value", kms_key_name="kms_key_name_value", ) - response = client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.UpdateRepositoryRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gda_repository.Repository) - assert response.name == "name_value" - assert response.format_ == gda_repository.Repository.Format.DOCKER - assert response.description == "description_value" - assert response.kms_key_name == "kms_key_name_value" @@ -1390,7 +1376,7 @@ def test_update_repository_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1400,7 +1386,6 @@ def test_update_repository_empty_call(): client.update_repository() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.UpdateRepositoryRequest() @@ -1409,7 +1394,7 @@ async def test_update_repository_async( transport: str = "grpc_asyncio", request_type=gda_repository.UpdateRepositoryRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1429,24 +1414,18 @@ async def test_update_repository_async( kms_key_name="kms_key_name_value", ) ) - response = await client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.UpdateRepositoryRequest() # Establish that the response is the type that we expect. assert isinstance(response, gda_repository.Repository) - assert response.name == "name_value" - assert response.format_ == gda_repository.Repository.Format.DOCKER - assert response.description == "description_value" - assert response.kms_key_name == "kms_key_name_value" @@ -1456,11 +1435,12 @@ async def test_update_repository_async_from_dict(): def test_update_repository_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = gda_repository.UpdateRepositoryRequest() + request.repository.name = "repository.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1468,7 +1448,6 @@ def test_update_repository_field_headers(): type(client.transport.update_repository), "__call__" ) as call: call.return_value = gda_repository.Repository() - client.update_repository(request) # Establish that the underlying gRPC stub method was called. @@ -1486,12 +1465,13 @@ def test_update_repository_field_headers(): @pytest.mark.asyncio async def test_update_repository_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = gda_repository.UpdateRepositoryRequest() + request.repository.name = "repository.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1501,7 +1481,6 @@ async def test_update_repository_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gda_repository.Repository() ) - await client.update_repository(request) # Establish that the underlying gRPC stub method was called. @@ -1517,7 +1496,7 @@ async def test_update_repository_field_headers_async(): def test_update_repository_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1525,26 +1504,23 @@ def test_update_repository_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gda_repository.Repository() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_repository( repository=gda_repository.Repository(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].repository == gda_repository.Repository(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_repository_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1552,14 +1528,14 @@ def test_update_repository_flattened_error(): client.update_repository( gda_repository.UpdateRepositoryRequest(), repository=gda_repository.Repository(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_repository_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1576,23 +1552,21 @@ async def test_update_repository_flattened_async(): # using the keyword arguments to the method. response = await client.update_repository( repository=gda_repository.Repository(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].repository == gda_repository.Repository(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_repository_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1601,7 +1575,7 @@ async def test_update_repository_flattened_error_async(): await client.update_repository( gda_repository.UpdateRepositoryRequest(), repository=gda_repository.Repository(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1609,7 +1583,7 @@ def test_delete_repository( transport: str = "grpc", request_type=repository.DeleteRepositoryRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1622,13 +1596,11 @@ def test_delete_repository( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == repository.DeleteRepositoryRequest() # Establish that the response is the type that we expect. @@ -1643,7 +1615,7 @@ def test_delete_repository_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1653,7 +1625,6 @@ def test_delete_repository_empty_call(): client.delete_repository() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == repository.DeleteRepositoryRequest() @@ -1662,7 +1633,7 @@ async def test_delete_repository_async( transport: str = "grpc_asyncio", request_type=repository.DeleteRepositoryRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1677,13 +1648,11 @@ async def test_delete_repository_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == repository.DeleteRepositoryRequest() # Establish that the response is the type that we expect. @@ -1696,11 +1665,12 @@ async def test_delete_repository_async_from_dict(): def test_delete_repository_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = repository.DeleteRepositoryRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1708,7 +1678,6 @@ def test_delete_repository_field_headers(): type(client.transport.delete_repository), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_repository(request) # Establish that the underlying gRPC stub method was called. @@ -1724,12 +1693,13 @@ def test_delete_repository_field_headers(): @pytest.mark.asyncio async def test_delete_repository_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = repository.DeleteRepositoryRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1739,7 +1709,6 @@ async def test_delete_repository_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_repository(request) # Establish that the underlying gRPC stub method was called. @@ -1753,7 +1722,7 @@ async def test_delete_repository_field_headers_async(): def test_delete_repository_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1761,7 +1730,6 @@ def test_delete_repository_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_repository(name="name_value",) @@ -1770,12 +1738,11 @@ def test_delete_repository_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_repository_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1788,7 +1755,7 @@ def test_delete_repository_flattened_error(): @pytest.mark.asyncio async def test_delete_repository_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1809,14 +1776,13 @@ async def test_delete_repository_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_repository_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1831,7 +1797,7 @@ def test_list_packages( transport: str = "grpc", request_type=package.ListPackagesRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1844,19 +1810,15 @@ def test_list_packages( call.return_value = package.ListPackagesResponse( next_page_token="next_page_token_value", ) - response = client.list_packages(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == package.ListPackagesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPackagesPager) - assert response.next_page_token == "next_page_token_value" @@ -1868,7 +1830,7 @@ def test_list_packages_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1876,7 +1838,6 @@ def test_list_packages_empty_call(): client.list_packages() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == package.ListPackagesRequest() @@ -1885,7 +1846,7 @@ async def test_list_packages_async( transport: str = "grpc_asyncio", request_type=package.ListPackagesRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1898,18 +1859,15 @@ async def test_list_packages_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( package.ListPackagesResponse(next_page_token="next_page_token_value",) ) - response = await client.list_packages(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == package.ListPackagesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListPackagesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1919,17 +1877,17 @@ async def test_list_packages_async_from_dict(): def test_list_packages_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = package.ListPackagesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_packages), "__call__") as call: call.return_value = package.ListPackagesResponse() - client.list_packages(request) # Establish that the underlying gRPC stub method was called. @@ -1945,12 +1903,13 @@ def test_list_packages_field_headers(): @pytest.mark.asyncio async def test_list_packages_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = package.ListPackagesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1958,7 +1917,6 @@ async def test_list_packages_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( package.ListPackagesResponse() ) - await client.list_packages(request) # Establish that the underlying gRPC stub method was called. @@ -1972,13 +1930,12 @@ async def test_list_packages_field_headers_async(): def test_list_packages_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_packages), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = package.ListPackagesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_packages(parent="parent_value",) @@ -1987,12 +1944,11 @@ def test_list_packages_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_packages_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2005,7 +1961,7 @@ def test_list_packages_flattened_error(): @pytest.mark.asyncio async def test_list_packages_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2024,14 +1980,13 @@ async def test_list_packages_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_packages_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2043,7 +1998,7 @@ async def test_list_packages_flattened_error_async(): def test_list_packages_pager(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_packages), "__call__") as call: @@ -2077,7 +2032,7 @@ def test_list_packages_pager(): def test_list_packages_pages(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_packages), "__call__") as call: @@ -2103,7 +2058,9 @@ def test_list_packages_pages(): @pytest.mark.asyncio async def test_list_packages_async_pager(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2136,7 +2093,9 @@ async def test_list_packages_async_pager(): @pytest.mark.asyncio async def test_list_packages_async_pages(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2166,7 +2125,7 @@ async def test_list_packages_async_pages(): def test_get_package(transport: str = "grpc", request_type=package.GetPackageRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2179,21 +2138,16 @@ def test_get_package(transport: str = "grpc", request_type=package.GetPackageReq call.return_value = package.Package( name="name_value", display_name="display_name_value", ) - response = client.get_package(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == package.GetPackageRequest() # Establish that the response is the type that we expect. - assert isinstance(response, package.Package) - assert response.name == "name_value" - assert response.display_name == "display_name_value" @@ -2205,7 +2159,7 @@ def test_get_package_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2213,7 +2167,6 @@ def test_get_package_empty_call(): client.get_package() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == package.GetPackageRequest() @@ -2222,7 +2175,7 @@ async def test_get_package_async( transport: str = "grpc_asyncio", request_type=package.GetPackageRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2235,20 +2188,16 @@ async def test_get_package_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( package.Package(name="name_value", display_name="display_name_value",) ) - response = await client.get_package(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == package.GetPackageRequest() # Establish that the response is the type that we expect. assert isinstance(response, package.Package) - assert response.name == "name_value" - assert response.display_name == "display_name_value" @@ -2258,17 +2207,17 @@ async def test_get_package_async_from_dict(): def test_get_package_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = package.GetPackageRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_package), "__call__") as call: call.return_value = package.Package() - client.get_package(request) # Establish that the underlying gRPC stub method was called. @@ -2284,18 +2233,18 @@ def test_get_package_field_headers(): @pytest.mark.asyncio async def test_get_package_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = package.GetPackageRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_package), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(package.Package()) - await client.get_package(request) # Establish that the underlying gRPC stub method was called. @@ -2309,13 +2258,12 @@ async def test_get_package_field_headers_async(): def test_get_package_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_package), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = package.Package() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_package(name="name_value",) @@ -2324,12 +2272,11 @@ def test_get_package_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_package_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2342,7 +2289,7 @@ def test_get_package_flattened_error(): @pytest.mark.asyncio async def test_get_package_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2359,14 +2306,13 @@ async def test_get_package_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_package_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2381,7 +2327,7 @@ def test_delete_package( transport: str = "grpc", request_type=package.DeletePackageRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2392,13 +2338,11 @@ def test_delete_package( with mock.patch.object(type(client.transport.delete_package), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_package(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == package.DeletePackageRequest() # Establish that the response is the type that we expect. @@ -2413,7 +2357,7 @@ def test_delete_package_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2421,7 +2365,6 @@ def test_delete_package_empty_call(): client.delete_package() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == package.DeletePackageRequest() @@ -2430,7 +2373,7 @@ async def test_delete_package_async( transport: str = "grpc_asyncio", request_type=package.DeletePackageRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2443,13 +2386,11 @@ async def test_delete_package_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_package(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == package.DeletePackageRequest() # Establish that the response is the type that we expect. @@ -2462,17 +2403,17 @@ async def test_delete_package_async_from_dict(): def test_delete_package_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = package.DeletePackageRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_package), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_package(request) # Establish that the underlying gRPC stub method was called. @@ -2488,12 +2429,13 @@ def test_delete_package_field_headers(): @pytest.mark.asyncio async def test_delete_package_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = package.DeletePackageRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2501,7 +2443,6 @@ async def test_delete_package_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_package(request) # Establish that the underlying gRPC stub method was called. @@ -2515,13 +2456,12 @@ async def test_delete_package_field_headers_async(): def test_delete_package_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_package), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_package(name="name_value",) @@ -2530,12 +2470,11 @@ def test_delete_package_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_package_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2548,7 +2487,7 @@ def test_delete_package_flattened_error(): @pytest.mark.asyncio async def test_delete_package_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2567,14 +2506,13 @@ async def test_delete_package_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_package_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2589,7 +2527,7 @@ def test_list_versions( transport: str = "grpc", request_type=version.ListVersionsRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2602,19 +2540,15 @@ def test_list_versions( call.return_value = version.ListVersionsResponse( next_page_token="next_page_token_value", ) - response = client.list_versions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == version.ListVersionsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsPager) - assert response.next_page_token == "next_page_token_value" @@ -2626,7 +2560,7 @@ def test_list_versions_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2634,7 +2568,6 @@ def test_list_versions_empty_call(): client.list_versions() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == version.ListVersionsRequest() @@ -2643,7 +2576,7 @@ async def test_list_versions_async( transport: str = "grpc_asyncio", request_type=version.ListVersionsRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2656,18 +2589,15 @@ async def test_list_versions_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( version.ListVersionsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_versions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == version.ListVersionsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListVersionsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2677,17 +2607,17 @@ async def test_list_versions_async_from_dict(): def test_list_versions_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = version.ListVersionsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_versions), "__call__") as call: call.return_value = version.ListVersionsResponse() - client.list_versions(request) # Establish that the underlying gRPC stub method was called. @@ -2703,12 +2633,13 @@ def test_list_versions_field_headers(): @pytest.mark.asyncio async def test_list_versions_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = version.ListVersionsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2716,7 +2647,6 @@ async def test_list_versions_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( version.ListVersionsResponse() ) - await client.list_versions(request) # Establish that the underlying gRPC stub method was called. @@ -2730,13 +2660,12 @@ async def test_list_versions_field_headers_async(): def test_list_versions_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_versions), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = version.ListVersionsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_versions(parent="parent_value",) @@ -2745,12 +2674,11 @@ def test_list_versions_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_versions_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2763,7 +2691,7 @@ def test_list_versions_flattened_error(): @pytest.mark.asyncio async def test_list_versions_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2782,14 +2710,13 @@ async def test_list_versions_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_versions_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2801,7 +2728,7 @@ async def test_list_versions_flattened_error_async(): def test_list_versions_pager(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_versions), "__call__") as call: @@ -2835,7 +2762,7 @@ def test_list_versions_pager(): def test_list_versions_pages(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_versions), "__call__") as call: @@ -2861,7 +2788,9 @@ def test_list_versions_pages(): @pytest.mark.asyncio async def test_list_versions_async_pager(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2894,7 +2823,9 @@ async def test_list_versions_async_pager(): @pytest.mark.asyncio async def test_list_versions_async_pages(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2924,7 +2855,7 @@ async def test_list_versions_async_pages(): def test_get_version(transport: str = "grpc", request_type=version.GetVersionRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2937,21 +2868,16 @@ def test_get_version(transport: str = "grpc", request_type=version.GetVersionReq call.return_value = version.Version( name="name_value", description="description_value", ) - response = client.get_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == version.GetVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, version.Version) - assert response.name == "name_value" - assert response.description == "description_value" @@ -2963,7 +2889,7 @@ def test_get_version_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2971,7 +2897,6 @@ def test_get_version_empty_call(): client.get_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == version.GetVersionRequest() @@ -2980,7 +2905,7 @@ async def test_get_version_async( transport: str = "grpc_asyncio", request_type=version.GetVersionRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2993,20 +2918,16 @@ async def test_get_version_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( version.Version(name="name_value", description="description_value",) ) - response = await client.get_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == version.GetVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, version.Version) - assert response.name == "name_value" - assert response.description == "description_value" @@ -3016,17 +2937,17 @@ async def test_get_version_async_from_dict(): def test_get_version_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = version.GetVersionRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_version), "__call__") as call: call.return_value = version.Version() - client.get_version(request) # Establish that the underlying gRPC stub method was called. @@ -3042,18 +2963,18 @@ def test_get_version_field_headers(): @pytest.mark.asyncio async def test_get_version_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = version.GetVersionRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_version), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.Version()) - await client.get_version(request) # Establish that the underlying gRPC stub method was called. @@ -3067,13 +2988,12 @@ async def test_get_version_field_headers_async(): def test_get_version_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_version), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = version.Version() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_version(name="name_value",) @@ -3082,12 +3002,11 @@ def test_get_version_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_version_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3100,7 +3019,7 @@ def test_get_version_flattened_error(): @pytest.mark.asyncio async def test_get_version_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3117,14 +3036,13 @@ async def test_get_version_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_version_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3139,7 +3057,7 @@ def test_delete_version( transport: str = "grpc", request_type=version.DeleteVersionRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3150,13 +3068,11 @@ def test_delete_version( with mock.patch.object(type(client.transport.delete_version), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == version.DeleteVersionRequest() # Establish that the response is the type that we expect. @@ -3171,7 +3087,7 @@ def test_delete_version_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3179,7 +3095,6 @@ def test_delete_version_empty_call(): client.delete_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == version.DeleteVersionRequest() @@ -3188,7 +3103,7 @@ async def test_delete_version_async( transport: str = "grpc_asyncio", request_type=version.DeleteVersionRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3201,13 +3116,11 @@ async def test_delete_version_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == version.DeleteVersionRequest() # Establish that the response is the type that we expect. @@ -3220,17 +3133,17 @@ async def test_delete_version_async_from_dict(): def test_delete_version_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = version.DeleteVersionRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_version), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_version(request) # Establish that the underlying gRPC stub method was called. @@ -3246,12 +3159,13 @@ def test_delete_version_field_headers(): @pytest.mark.asyncio async def test_delete_version_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = version.DeleteVersionRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3259,7 +3173,6 @@ async def test_delete_version_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_version(request) # Establish that the underlying gRPC stub method was called. @@ -3273,13 +3186,12 @@ async def test_delete_version_field_headers_async(): def test_delete_version_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_version), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_version(name="name_value",) @@ -3288,12 +3200,11 @@ def test_delete_version_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_version_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3306,7 +3217,7 @@ def test_delete_version_flattened_error(): @pytest.mark.asyncio async def test_delete_version_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3325,14 +3236,13 @@ async def test_delete_version_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_version_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3345,7 +3255,7 @@ async def test_delete_version_flattened_error_async(): def test_list_files(transport: str = "grpc", request_type=file.ListFilesRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3358,19 +3268,15 @@ def test_list_files(transport: str = "grpc", request_type=file.ListFilesRequest) call.return_value = file.ListFilesResponse( next_page_token="next_page_token_value", ) - response = client.list_files(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == file.ListFilesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesPager) - assert response.next_page_token == "next_page_token_value" @@ -3382,7 +3288,7 @@ def test_list_files_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3390,7 +3296,6 @@ def test_list_files_empty_call(): client.list_files() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == file.ListFilesRequest() @@ -3399,7 +3304,7 @@ async def test_list_files_async( transport: str = "grpc_asyncio", request_type=file.ListFilesRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3412,18 +3317,15 @@ async def test_list_files_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( file.ListFilesResponse(next_page_token="next_page_token_value",) ) - response = await client.list_files(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == file.ListFilesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFilesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -3433,17 +3335,17 @@ async def test_list_files_async_from_dict(): def test_list_files_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = file.ListFilesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_files), "__call__") as call: call.return_value = file.ListFilesResponse() - client.list_files(request) # Establish that the underlying gRPC stub method was called. @@ -3459,12 +3361,13 @@ def test_list_files_field_headers(): @pytest.mark.asyncio async def test_list_files_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = file.ListFilesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3472,7 +3375,6 @@ async def test_list_files_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( file.ListFilesResponse() ) - await client.list_files(request) # Establish that the underlying gRPC stub method was called. @@ -3486,13 +3388,12 @@ async def test_list_files_field_headers_async(): def test_list_files_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_files), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = file.ListFilesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_files(parent="parent_value",) @@ -3501,12 +3402,11 @@ def test_list_files_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_files_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3519,7 +3419,7 @@ def test_list_files_flattened_error(): @pytest.mark.asyncio async def test_list_files_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3538,14 +3438,13 @@ async def test_list_files_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_files_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3557,7 +3456,7 @@ async def test_list_files_flattened_error_async(): def test_list_files_pager(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_files), "__call__") as call: @@ -3586,7 +3485,7 @@ def test_list_files_pager(): def test_list_files_pages(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_files), "__call__") as call: @@ -3607,7 +3506,9 @@ def test_list_files_pages(): @pytest.mark.asyncio async def test_list_files_async_pager(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3635,7 +3536,9 @@ async def test_list_files_async_pager(): @pytest.mark.asyncio async def test_list_files_async_pages(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3660,7 +3563,7 @@ async def test_list_files_async_pages(): def test_get_file(transport: str = "grpc", request_type=file.GetFileRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3673,23 +3576,17 @@ def test_get_file(transport: str = "grpc", request_type=file.GetFileRequest): call.return_value = file.File( name="name_value", size_bytes=1089, owner="owner_value", ) - response = client.get_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == file.GetFileRequest() # Establish that the response is the type that we expect. - assert isinstance(response, file.File) - assert response.name == "name_value" - assert response.size_bytes == 1089 - assert response.owner == "owner_value" @@ -3701,7 +3598,7 @@ def test_get_file_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3709,7 +3606,6 @@ def test_get_file_empty_call(): client.get_file() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == file.GetFileRequest() @@ -3718,7 +3614,7 @@ async def test_get_file_async( transport: str = "grpc_asyncio", request_type=file.GetFileRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3731,22 +3627,17 @@ async def test_get_file_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( file.File(name="name_value", size_bytes=1089, owner="owner_value",) ) - response = await client.get_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == file.GetFileRequest() # Establish that the response is the type that we expect. assert isinstance(response, file.File) - assert response.name == "name_value" - assert response.size_bytes == 1089 - assert response.owner == "owner_value" @@ -3756,17 +3647,17 @@ async def test_get_file_async_from_dict(): def test_get_file_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = file.GetFileRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_file), "__call__") as call: call.return_value = file.File() - client.get_file(request) # Establish that the underlying gRPC stub method was called. @@ -3782,18 +3673,18 @@ def test_get_file_field_headers(): @pytest.mark.asyncio async def test_get_file_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = file.GetFileRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_file), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.File()) - await client.get_file(request) # Establish that the underlying gRPC stub method was called. @@ -3807,13 +3698,12 @@ async def test_get_file_field_headers_async(): def test_get_file_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_file), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = file.File() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_file(name="name_value",) @@ -3822,12 +3712,11 @@ def test_get_file_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_file_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3840,7 +3729,7 @@ def test_get_file_flattened_error(): @pytest.mark.asyncio async def test_get_file_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3857,14 +3746,13 @@ async def test_get_file_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_file_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3877,7 +3765,7 @@ async def test_get_file_flattened_error_async(): def test_list_tags(transport: str = "grpc", request_type=tag.ListTagsRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3890,19 +3778,15 @@ def test_list_tags(transport: str = "grpc", request_type=tag.ListTagsRequest): call.return_value = tag.ListTagsResponse( next_page_token="next_page_token_value", ) - response = client.list_tags(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tag.ListTagsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsPager) - assert response.next_page_token == "next_page_token_value" @@ -3914,7 +3798,7 @@ def test_list_tags_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3922,7 +3806,6 @@ def test_list_tags_empty_call(): client.list_tags() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.ListTagsRequest() @@ -3931,7 +3814,7 @@ async def test_list_tags_async( transport: str = "grpc_asyncio", request_type=tag.ListTagsRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3944,18 +3827,15 @@ async def test_list_tags_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tag.ListTagsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_tags(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tag.ListTagsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTagsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -3965,17 +3845,17 @@ async def test_list_tags_async_from_dict(): def test_list_tags_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = tag.ListTagsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tags), "__call__") as call: call.return_value = tag.ListTagsResponse() - client.list_tags(request) # Establish that the underlying gRPC stub method was called. @@ -3991,12 +3871,13 @@ def test_list_tags_field_headers(): @pytest.mark.asyncio async def test_list_tags_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = tag.ListTagsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4004,7 +3885,6 @@ async def test_list_tags_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tag.ListTagsResponse() ) - await client.list_tags(request) # Establish that the underlying gRPC stub method was called. @@ -4018,13 +3898,12 @@ async def test_list_tags_field_headers_async(): def test_list_tags_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tags), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tag.ListTagsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_tags(parent="parent_value",) @@ -4033,12 +3912,11 @@ def test_list_tags_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_tags_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4051,7 +3929,7 @@ def test_list_tags_flattened_error(): @pytest.mark.asyncio async def test_list_tags_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4070,14 +3948,13 @@ async def test_list_tags_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_tags_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4089,7 +3966,7 @@ async def test_list_tags_flattened_error_async(): def test_list_tags_pager(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tags), "__call__") as call: @@ -4118,7 +3995,7 @@ def test_list_tags_pager(): def test_list_tags_pages(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tags), "__call__") as call: @@ -4139,7 +4016,9 @@ def test_list_tags_pages(): @pytest.mark.asyncio async def test_list_tags_async_pager(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4167,7 +4046,9 @@ async def test_list_tags_async_pager(): @pytest.mark.asyncio async def test_list_tags_async_pages(): - client = ArtifactRegistryAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4192,7 +4073,7 @@ async def test_list_tags_async_pages(): def test_get_tag(transport: str = "grpc", request_type=tag.GetTagRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4203,21 +4084,16 @@ def test_get_tag(transport: str = "grpc", request_type=tag.GetTagRequest): with mock.patch.object(type(client.transport.get_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tag.Tag(name="name_value", version="version_value",) - response = client.get_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tag.GetTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) - assert response.name == "name_value" - assert response.version == "version_value" @@ -4229,7 +4105,7 @@ def test_get_tag_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4237,7 +4113,6 @@ def test_get_tag_empty_call(): client.get_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.GetTagRequest() @@ -4246,7 +4121,7 @@ async def test_get_tag_async( transport: str = "grpc_asyncio", request_type=tag.GetTagRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4259,20 +4134,16 @@ async def test_get_tag_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tag.Tag(name="name_value", version="version_value",) ) - response = await client.get_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tag.GetTagRequest() # Establish that the response is the type that we expect. assert isinstance(response, tag.Tag) - assert response.name == "name_value" - assert response.version == "version_value" @@ -4282,17 +4153,17 @@ async def test_get_tag_async_from_dict(): def test_get_tag_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = tag.GetTagRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_tag), "__call__") as call: call.return_value = tag.Tag() - client.get_tag(request) # Establish that the underlying gRPC stub method was called. @@ -4308,18 +4179,18 @@ def test_get_tag_field_headers(): @pytest.mark.asyncio async def test_get_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = tag.GetTagRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_tag), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag()) - await client.get_tag(request) # Establish that the underlying gRPC stub method was called. @@ -4333,13 +4204,12 @@ async def test_get_tag_field_headers_async(): def test_get_tag_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tag.Tag() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_tag(name="name_value",) @@ -4348,12 +4218,11 @@ def test_get_tag_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_tag_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4366,7 +4235,7 @@ def test_get_tag_flattened_error(): @pytest.mark.asyncio async def test_get_tag_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4383,14 +4252,13 @@ async def test_get_tag_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4403,7 +4271,7 @@ async def test_get_tag_flattened_error_async(): def test_create_tag(transport: str = "grpc", request_type=gda_tag.CreateTagRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4414,21 +4282,16 @@ def test_create_tag(transport: str = "grpc", request_type=gda_tag.CreateTagReque with mock.patch.object(type(client.transport.create_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gda_tag.Tag(name="name_value", version="version_value",) - response = client.create_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.CreateTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gda_tag.Tag) - assert response.name == "name_value" - assert response.version == "version_value" @@ -4440,7 +4303,7 @@ def test_create_tag_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4448,7 +4311,6 @@ def test_create_tag_empty_call(): client.create_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.CreateTagRequest() @@ -4457,7 +4319,7 @@ async def test_create_tag_async( transport: str = "grpc_asyncio", request_type=gda_tag.CreateTagRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4470,20 +4332,16 @@ async def test_create_tag_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gda_tag.Tag(name="name_value", version="version_value",) ) - response = await client.create_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.CreateTagRequest() # Establish that the response is the type that we expect. assert isinstance(response, gda_tag.Tag) - assert response.name == "name_value" - assert response.version == "version_value" @@ -4493,17 +4351,17 @@ async def test_create_tag_async_from_dict(): def test_create_tag_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = gda_tag.CreateTagRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_tag), "__call__") as call: call.return_value = gda_tag.Tag() - client.create_tag(request) # Establish that the underlying gRPC stub method was called. @@ -4519,18 +4377,18 @@ def test_create_tag_field_headers(): @pytest.mark.asyncio async def test_create_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = gda_tag.CreateTagRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_tag), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) - await client.create_tag(request) # Establish that the underlying gRPC stub method was called. @@ -4544,13 +4402,12 @@ async def test_create_tag_field_headers_async(): def test_create_tag_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gda_tag.Tag() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_tag( @@ -4563,16 +4420,13 @@ def test_create_tag_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].tag == gda_tag.Tag(name="name_value") - assert args[0].tag_id == "tag_id_value" def test_create_tag_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4588,7 +4442,7 @@ def test_create_tag_flattened_error(): @pytest.mark.asyncio async def test_create_tag_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4609,18 +4463,15 @@ async def test_create_tag_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].tag == gda_tag.Tag(name="name_value") - assert args[0].tag_id == "tag_id_value" @pytest.mark.asyncio async def test_create_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4636,7 +4487,7 @@ async def test_create_tag_flattened_error_async(): def test_update_tag(transport: str = "grpc", request_type=gda_tag.UpdateTagRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4647,21 +4498,16 @@ def test_update_tag(transport: str = "grpc", request_type=gda_tag.UpdateTagReque with mock.patch.object(type(client.transport.update_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gda_tag.Tag(name="name_value", version="version_value",) - response = client.update_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.UpdateTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gda_tag.Tag) - assert response.name == "name_value" - assert response.version == "version_value" @@ -4673,7 +4519,7 @@ def test_update_tag_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4681,7 +4527,6 @@ def test_update_tag_empty_call(): client.update_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.UpdateTagRequest() @@ -4690,7 +4535,7 @@ async def test_update_tag_async( transport: str = "grpc_asyncio", request_type=gda_tag.UpdateTagRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4703,20 +4548,16 @@ async def test_update_tag_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gda_tag.Tag(name="name_value", version="version_value",) ) - response = await client.update_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.UpdateTagRequest() # Establish that the response is the type that we expect. assert isinstance(response, gda_tag.Tag) - assert response.name == "name_value" - assert response.version == "version_value" @@ -4726,17 +4567,17 @@ async def test_update_tag_async_from_dict(): def test_update_tag_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = gda_tag.UpdateTagRequest() + request.tag.name = "tag.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_tag), "__call__") as call: call.return_value = gda_tag.Tag() - client.update_tag(request) # Establish that the underlying gRPC stub method was called. @@ -4752,18 +4593,18 @@ def test_update_tag_field_headers(): @pytest.mark.asyncio async def test_update_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = gda_tag.UpdateTagRequest() + request.tag.name = "tag.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_tag), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) - await client.update_tag(request) # Establish that the underlying gRPC stub method was called. @@ -4777,32 +4618,29 @@ async def test_update_tag_field_headers_async(): def test_update_tag_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gda_tag.Tag() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_tag( tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].tag == gda_tag.Tag(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_tag_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4810,14 +4648,14 @@ def test_update_tag_flattened_error(): client.update_tag( gda_tag.UpdateTagRequest(), tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_tag_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4830,23 +4668,21 @@ async def test_update_tag_flattened_async(): # using the keyword arguments to the method. response = await client.update_tag( tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].tag == gda_tag.Tag(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4855,13 +4691,13 @@ async def test_update_tag_flattened_error_async(): await client.update_tag( gda_tag.UpdateTagRequest(), tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) def test_delete_tag(transport: str = "grpc", request_type=tag.DeleteTagRequest): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4872,13 +4708,11 @@ def test_delete_tag(transport: str = "grpc", request_type=tag.DeleteTagRequest): with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tag.DeleteTagRequest() # Establish that the response is the type that we expect. @@ -4893,7 +4727,7 @@ def test_delete_tag_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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4901,7 +4735,6 @@ def test_delete_tag_empty_call(): client.delete_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.DeleteTagRequest() @@ -4910,7 +4743,7 @@ async def test_delete_tag_async( transport: str = "grpc_asyncio", request_type=tag.DeleteTagRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4921,13 +4754,11 @@ async def test_delete_tag_async( with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tag.DeleteTagRequest() # Establish that the response is the type that we expect. @@ -4940,17 +4771,17 @@ async def test_delete_tag_async_from_dict(): def test_delete_tag_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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 = tag.DeleteTagRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: call.return_value = None - client.delete_tag(request) # Establish that the underlying gRPC stub method was called. @@ -4966,18 +4797,18 @@ def test_delete_tag_field_headers(): @pytest.mark.asyncio async def test_delete_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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 = tag.DeleteTagRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_tag(request) # Establish that the underlying gRPC stub method was called. @@ -4991,13 +4822,12 @@ async def test_delete_tag_field_headers_async(): def test_delete_tag_flattened(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_tag(name="name_value",) @@ -5006,12 +4836,11 @@ def test_delete_tag_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_tag_flattened_error(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5024,7 +4853,7 @@ def test_delete_tag_flattened_error(): @pytest.mark.asyncio async def test_delete_tag_flattened_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5041,14 +4870,13 @@ async def test_delete_tag_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5060,10 +4888,10 @@ async def test_delete_tag_flattened_error_async(): def test_set_iam_policy( - transport: str = "grpc", request_type=iam_policy.SetIamPolicyRequest + transport: str = "grpc", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5073,22 +4901,17 @@ def test_set_iam_policy( # 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.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. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, policy.Policy) - + assert isinstance(response, policy_pb2.Policy) assert response.version == 774 - assert response.etag == b"etag_blob" @@ -5100,7 +4923,7 @@ 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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5108,16 +4931,15 @@ def test_set_iam_policy_empty_call(): client.set_iam_policy() call.assert_called() _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() @pytest.mark.asyncio async def test_set_iam_policy_async( - transport: str = "grpc_asyncio", request_type=iam_policy.SetIamPolicyRequest + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5128,22 +4950,18 @@ 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.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy(version=774, etag=b"etag_blob",) ) - response = await client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, policy.Policy) - + assert isinstance(response, policy_pb2.Policy) assert response.version == 774 - assert response.etag == b"etag_blob" @@ -5153,17 +4971,17 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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.SetIamPolicyRequest() + request = iam_policy_pb2.SetIamPolicyRequest() + 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: - call.return_value = policy.Policy() - + call.return_value = policy_pb2.Policy() client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -5179,18 +4997,18 @@ def test_set_iam_policy_field_headers(): @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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.SetIamPolicyRequest() + request = iam_policy_pb2.SetIamPolicyRequest() + 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: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) - + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) await client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -5204,26 +5022,25 @@ async def test_set_iam_policy_field_headers_async(): def test_set_iam_policy_from_dict_foreign(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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. - call.return_value = policy.Policy() - + call.return_value = policy_pb2.Policy() response = client.set_iam_policy( request={ "resource": "resource_value", - "policy": policy.Policy(version=774), + "policy": policy_pb2.Policy(version=774), } ) call.assert_called() def test_get_iam_policy( - transport: str = "grpc", request_type=iam_policy.GetIamPolicyRequest + transport: str = "grpc", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5233,22 +5050,17 @@ def test_get_iam_policy( # 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.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. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.GetIamPolicyRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, policy.Policy) - + assert isinstance(response, policy_pb2.Policy) assert response.version == 774 - assert response.etag == b"etag_blob" @@ -5260,7 +5072,7 @@ 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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5268,16 +5080,15 @@ def test_get_iam_policy_empty_call(): client.get_iam_policy() call.assert_called() _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.GetIamPolicyRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() @pytest.mark.asyncio async def test_get_iam_policy_async( - transport: str = "grpc_asyncio", request_type=iam_policy.GetIamPolicyRequest + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5288,22 +5099,18 @@ 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.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy(version=774, etag=b"etag_blob",) ) - response = await client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.GetIamPolicyRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, policy.Policy) - + assert isinstance(response, policy_pb2.Policy) assert response.version == 774 - assert response.etag == b"etag_blob" @@ -5313,17 +5120,17 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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.GetIamPolicyRequest() + request = iam_policy_pb2.GetIamPolicyRequest() + 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: - call.return_value = policy.Policy() - + call.return_value = policy_pb2.Policy() client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -5339,18 +5146,18 @@ def test_get_iam_policy_field_headers(): @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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.GetIamPolicyRequest() + request = iam_policy_pb2.GetIamPolicyRequest() + 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: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) - + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) await client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -5364,26 +5171,25 @@ async def test_get_iam_policy_field_headers_async(): def test_get_iam_policy_from_dict_foreign(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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. - call.return_value = policy.Policy() - + call.return_value = policy_pb2.Policy() response = client.get_iam_policy( request={ "resource": "resource_value", - "options": options.GetPolicyOptions(requested_policy_version=2598), + "options": options_pb2.GetPolicyOptions(requested_policy_version=2598), } ) call.assert_called() def test_test_iam_permissions( - transport: str = "grpc", request_type=iam_policy.TestIamPermissionsRequest + transport: str = "grpc", request_type=iam_policy_pb2.TestIamPermissionsRequest ): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5395,22 +5201,18 @@ def test_test_iam_permissions( type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy.TestIamPermissionsResponse( + call.return_value = iam_policy_pb2.TestIamPermissionsResponse( permissions=["permissions_value"], ) - response = client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.TestIamPermissionsRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, iam_policy.TestIamPermissionsResponse) - + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) assert response.permissions == ["permissions_value"] @@ -5422,7 +5224,7 @@ 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 = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5432,16 +5234,16 @@ def test_test_iam_permissions_empty_call(): client.test_iam_permissions() call.assert_called() _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.TestIamPermissionsRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() @pytest.mark.asyncio async def test_test_iam_permissions_async( - transport: str = "grpc_asyncio", request_type=iam_policy.TestIamPermissionsRequest + transport: str = "grpc_asyncio", + request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5454,20 +5256,19 @@ async def test_test_iam_permissions_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy.TestIamPermissionsResponse(permissions=["permissions_value"],) + iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) ) - response = await client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0] == iam_policy.TestIamPermissionsRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy.TestIamPermissionsResponse) - + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) assert response.permissions == ["permissions_value"] @@ -5477,19 +5278,19 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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.TestIamPermissionsRequest() + request = iam_policy_pb2.TestIamPermissionsRequest() + request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" ) as call: - call.return_value = iam_policy.TestIamPermissionsResponse() - + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. @@ -5505,12 +5306,13 @@ def test_test_iam_permissions_field_headers(): @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), + 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.TestIamPermissionsRequest() + request = iam_policy_pb2.TestIamPermissionsRequest() + request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5518,9 +5320,8 @@ async def test_test_iam_permissions_field_headers_async(): type(client.transport.test_iam_permissions), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy.TestIamPermissionsResponse() + iam_policy_pb2.TestIamPermissionsResponse() ) - await client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. @@ -5534,14 +5335,13 @@ async def test_test_iam_permissions_field_headers_async(): def test_test_iam_permissions_from_dict_foreign(): - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(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__" ) as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy.TestIamPermissionsResponse() - + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() response = client.test_iam_permissions( request={ "resource": "resource_value", @@ -5554,16 +5354,16 @@ def test_test_iam_permissions_from_dict_foreign(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ArtifactRegistryGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.ArtifactRegistryGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ArtifactRegistryClient( @@ -5573,7 +5373,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.ArtifactRegistryGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ArtifactRegistryClient( @@ -5584,7 +5384,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.ArtifactRegistryGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = ArtifactRegistryClient(transport=transport) assert client.transport is transport @@ -5593,13 +5393,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.ArtifactRegistryGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.ArtifactRegistryGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -5614,23 +5414,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = ArtifactRegistryClient(credentials=credentials.AnonymousCredentials(),) + client = ArtifactRegistryClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.ArtifactRegistryGrpcTransport,) def test_artifact_registry_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.ArtifactRegistryTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -5642,7 +5442,7 @@ def test_artifact_registry_base_transport(): ) as Transport: Transport.return_value = None transport = transports.ArtifactRegistryTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -5680,15 +5480,40 @@ def test_artifact_registry_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_artifact_registry_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.ArtifactRegistryTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.ArtifactRegistryTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + ), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_artifact_registry_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.ArtifactRegistryTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ArtifactRegistryTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -5704,19 +5529,36 @@ def test_artifact_registry_base_transport_with_credentials_file(): def test_artifact_registry_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.ArtifactRegistryTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ArtifactRegistryTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_artifact_registry_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + ArtifactRegistryClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + ), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_artifact_registry_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) ArtifactRegistryClient() adc.assert_called_once_with( scopes=( @@ -5727,14 +5569,44 @@ def test_artifact_registry_auth_adc(): ) -def test_artifact_registry_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.ArtifactRegistryGrpcTransport, + transports.ArtifactRegistryGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_artifact_registry_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.ArtifactRegistryGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + ), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ArtifactRegistryGrpcTransport, + transports.ArtifactRegistryGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_artifact_registry_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=( "https://www.googleapis.com/auth/cloud-platform", @@ -5744,6 +5616,121 @@ def test_artifact_registry_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ArtifactRegistryGrpcTransport, grpc_helpers), + (transports.ArtifactRegistryGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_artifact_registry_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "artifactregistry.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + ), + scopes=["1", "2"], + default_host="artifactregistry.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ArtifactRegistryGrpcTransport, grpc_helpers), + (transports.ArtifactRegistryGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_artifact_registry_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "artifactregistry.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + ), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ArtifactRegistryGrpcTransport, grpc_helpers), + (transports.ArtifactRegistryGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_artifact_registry_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "artifactregistry.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -5752,7 +5739,7 @@ def test_artifact_registry_transport_auth_adc(): ], ) def test_artifact_registry_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -5794,7 +5781,7 @@ def test_artifact_registry_grpc_transport_client_cert_source_for_mtls(transport_ def test_artifact_registry_host_no_port(): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="artifactregistry.googleapis.com" ), @@ -5804,7 +5791,7 @@ def test_artifact_registry_host_no_port(): def test_artifact_registry_host_with_port(): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="artifactregistry.googleapis.com:8000" ), @@ -5860,9 +5847,9 @@ def test_artifact_registry_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -5944,7 +5931,7 @@ def test_artifact_registry_transport_channel_mtls_with_adc(transport_class): def test_artifact_registry_grpc_lro_client(): client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -5957,7 +5944,7 @@ def test_artifact_registry_grpc_lro_client(): def test_artifact_registry_grpc_lro_async_client(): client = ArtifactRegistryAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -5973,7 +5960,6 @@ def test_file_path(): location = "clam" repo = "whelk" file = "octopus" - expected = "projects/{project}/locations/{location}/repositories/{repo}/files/{file}".format( project=project, location=location, repo=repo, file=file, ) @@ -5999,7 +5985,6 @@ def test_repository_path(): project = "winkle" location = "nautilus" repository = "scallop" - expected = "projects/{project}/locations/{location}/repositories/{repository}".format( project=project, location=location, repository=repository, ) @@ -6022,7 +6007,6 @@ def test_parse_repository_path(): def test_common_billing_account_path(): billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -6043,7 +6027,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) actual = ArtifactRegistryClient.common_folder_path(folder) assert expected == actual @@ -6062,7 +6045,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) actual = ArtifactRegistryClient.common_organization_path(organization) assert expected == actual @@ -6081,7 +6063,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) actual = ArtifactRegistryClient.common_project_path(project) assert expected == actual @@ -6101,7 +6082,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "scallop" location = "abalone" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -6128,7 +6108,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.ArtifactRegistryTransport, "_prep_wrapped_messages" ) as prep: client = ArtifactRegistryClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -6137,6 +6117,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = ArtifactRegistryClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)