diff --git a/.coveragerc b/.coveragerc index 07b5fc2..5fe8843 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,6 +5,7 @@ branch = True show_missing = True omit = google/cloud/artifactregistry/__init__.py + google/cloud/artifactregistry/gapic_version.py exclude_lines = # Re-enable the standard pragma pragma: NO COVER diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 889f77d..f0f3b24 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:c43f1d918bcf817d337aa29ff833439494a158a0831508fda4ec75dc4c0d0320 + digest: sha256:f946c75373c2b0040e8e318c5e85d0cf46bc6e61d0a01f3ef94d8de974ac6790 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 093be7e..64e0684 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.6.1" + ".": "1.7.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e6a45b..e896313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [1.7.0](https://github.com/googleapis/python-artifact-registry/compare/v1.6.1...v1.7.0) (2023-02-04) + + +### Features + +* Add `BatchDeleteVersionMetadata` to return version that failed to delete ([bed057d](https://github.com/googleapis/python-artifact-registry/commit/bed057d56e91a912dacdc0d1428e801c91fff307)) +* Add `order_by` to `ListDockerImages` ([bed057d](https://github.com/googleapis/python-artifact-registry/commit/bed057d56e91a912dacdc0d1428e801c91fff307)) +* Add an API to get and update VPCSC config ([bed057d](https://github.com/googleapis/python-artifact-registry/commit/bed057d56e91a912dacdc0d1428e801c91fff307)) +* Add format-specific resources `MavenArtifact`, `NpmPackage`, `KfpArtifact` and `PythonPackage` ([bed057d](https://github.com/googleapis/python-artifact-registry/commit/bed057d56e91a912dacdc0d1428e801c91fff307)) + + +### Bug Fixes + +* Deprecate `REDIRECTION_FROM_GCR_IO_FINALIZED` ([bed057d](https://github.com/googleapis/python-artifact-registry/commit/bed057d56e91a912dacdc0d1428e801c91fff307)) +* Make `GetFileRequest.name` and `ListFilesRequest.parent` required ([bed057d](https://github.com/googleapis/python-artifact-registry/commit/bed057d56e91a912dacdc0d1428e801c91fff307)) +* Make `Package` a resource ([bed057d](https://github.com/googleapis/python-artifact-registry/commit/bed057d56e91a912dacdc0d1428e801c91fff307)) + ## [1.6.1](https://github.com/googleapis/python-artifact-registry/compare/v1.6.0...v1.6.1) (2023-01-20) diff --git a/google/cloud/artifactregistry/__init__.py b/google/cloud/artifactregistry/__init__.py index 9b907da..eb9b670 100644 --- a/google/cloud/artifactregistry/__init__.py +++ b/google/cloud/artifactregistry/__init__.py @@ -35,8 +35,20 @@ from google.cloud.artifactregistry_v1.types.artifact import ( DockerImage, GetDockerImageRequest, + GetMavenArtifactRequest, + GetNpmPackageRequest, + GetPythonPackageRequest, ListDockerImagesRequest, ListDockerImagesResponse, + ListMavenArtifactsRequest, + ListMavenArtifactsResponse, + ListNpmPackagesRequest, + ListNpmPackagesResponse, + ListPythonPackagesRequest, + ListPythonPackagesResponse, + MavenArtifact, + NpmPackage, + PythonPackage, ) from google.cloud.artifactregistry_v1.types.file import ( File, @@ -77,6 +89,7 @@ UpdateTagRequest, ) from google.cloud.artifactregistry_v1.types.version import ( + BatchDeleteVersionsMetadata, DeleteVersionRequest, GetVersionRequest, ListVersionsRequest, @@ -84,6 +97,11 @@ Version, VersionView, ) +from google.cloud.artifactregistry_v1.types.vpcsc_config import ( + GetVPCSCConfigRequest, + UpdateVPCSCConfigRequest, + VPCSCConfig, +) from google.cloud.artifactregistry_v1.types.yum_artifact import ( ImportYumArtifactsErrorInfo, ImportYumArtifactsGcsSource, @@ -104,8 +122,20 @@ "ImportAptArtifactsResponse", "DockerImage", "GetDockerImageRequest", + "GetMavenArtifactRequest", + "GetNpmPackageRequest", + "GetPythonPackageRequest", "ListDockerImagesRequest", "ListDockerImagesResponse", + "ListMavenArtifactsRequest", + "ListMavenArtifactsResponse", + "ListNpmPackagesRequest", + "ListNpmPackagesResponse", + "ListPythonPackagesRequest", + "ListPythonPackagesResponse", + "MavenArtifact", + "NpmPackage", + "PythonPackage", "File", "GetFileRequest", "Hash", @@ -134,12 +164,16 @@ "ListTagsResponse", "Tag", "UpdateTagRequest", + "BatchDeleteVersionsMetadata", "DeleteVersionRequest", "GetVersionRequest", "ListVersionsRequest", "ListVersionsResponse", "Version", "VersionView", + "GetVPCSCConfigRequest", + "UpdateVPCSCConfigRequest", + "VPCSCConfig", "ImportYumArtifactsErrorInfo", "ImportYumArtifactsGcsSource", "ImportYumArtifactsMetadata", diff --git a/google/cloud/artifactregistry/gapic_version.py b/google/cloud/artifactregistry/gapic_version.py index b4028ab..f033c61 100644 --- a/google/cloud/artifactregistry/gapic_version.py +++ b/google/cloud/artifactregistry/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.1" # {x-release-please-version} +__version__ = "1.7.0" # {x-release-please-version} diff --git a/google/cloud/artifactregistry_v1/__init__.py b/google/cloud/artifactregistry_v1/__init__.py index 5096b78..0744c62 100644 --- a/google/cloud/artifactregistry_v1/__init__.py +++ b/google/cloud/artifactregistry_v1/__init__.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from google.cloud.artifactregistry import gapic_version as package_version +from google.cloud.artifactregistry_v1 import gapic_version as package_version __version__ = package_version.__version__ @@ -33,8 +33,20 @@ from .types.artifact import ( DockerImage, GetDockerImageRequest, + GetMavenArtifactRequest, + GetNpmPackageRequest, + GetPythonPackageRequest, ListDockerImagesRequest, ListDockerImagesResponse, + ListMavenArtifactsRequest, + ListMavenArtifactsResponse, + ListNpmPackagesRequest, + ListNpmPackagesResponse, + ListPythonPackagesRequest, + ListPythonPackagesResponse, + MavenArtifact, + NpmPackage, + PythonPackage, ) from .types.file import File, GetFileRequest, Hash, ListFilesRequest, ListFilesResponse from .types.package import ( @@ -69,6 +81,7 @@ UpdateTagRequest, ) from .types.version import ( + BatchDeleteVersionsMetadata, DeleteVersionRequest, GetVersionRequest, ListVersionsRequest, @@ -76,6 +89,11 @@ Version, VersionView, ) +from .types.vpcsc_config import ( + GetVPCSCConfigRequest, + UpdateVPCSCConfigRequest, + VPCSCConfig, +) from .types.yum_artifact import ( ImportYumArtifactsErrorInfo, ImportYumArtifactsGcsSource, @@ -89,6 +107,7 @@ "ArtifactRegistryAsyncClient", "AptArtifact", "ArtifactRegistryClient", + "BatchDeleteVersionsMetadata", "CreateRepositoryRequest", "CreateTagRequest", "DeletePackageRequest", @@ -99,10 +118,14 @@ "File", "GetDockerImageRequest", "GetFileRequest", + "GetMavenArtifactRequest", + "GetNpmPackageRequest", "GetPackageRequest", "GetProjectSettingsRequest", + "GetPythonPackageRequest", "GetRepositoryRequest", "GetTagRequest", + "GetVPCSCConfigRequest", "GetVersionRequest", "Hash", "ImportAptArtifactsErrorInfo", @@ -119,22 +142,33 @@ "ListDockerImagesResponse", "ListFilesRequest", "ListFilesResponse", + "ListMavenArtifactsRequest", + "ListMavenArtifactsResponse", + "ListNpmPackagesRequest", + "ListNpmPackagesResponse", "ListPackagesRequest", "ListPackagesResponse", + "ListPythonPackagesRequest", + "ListPythonPackagesResponse", "ListRepositoriesRequest", "ListRepositoriesResponse", "ListTagsRequest", "ListTagsResponse", "ListVersionsRequest", "ListVersionsResponse", + "MavenArtifact", + "NpmPackage", "OperationMetadata", "Package", "ProjectSettings", + "PythonPackage", "Repository", "Tag", "UpdateProjectSettingsRequest", "UpdateRepositoryRequest", "UpdateTagRequest", + "UpdateVPCSCConfigRequest", + "VPCSCConfig", "Version", "VersionView", "YumArtifact", diff --git a/google/cloud/artifactregistry_v1/gapic_metadata.json b/google/cloud/artifactregistry_v1/gapic_metadata.json index b2daf4f..b505760 100644 --- a/google/cloud/artifactregistry_v1/gapic_metadata.json +++ b/google/cloud/artifactregistry_v1/gapic_metadata.json @@ -55,6 +55,16 @@ "get_iam_policy" ] }, + "GetMavenArtifact": { + "methods": [ + "get_maven_artifact" + ] + }, + "GetNpmPackage": { + "methods": [ + "get_npm_package" + ] + }, "GetPackage": { "methods": [ "get_package" @@ -65,6 +75,11 @@ "get_project_settings" ] }, + "GetPythonPackage": { + "methods": [ + "get_python_package" + ] + }, "GetRepository": { "methods": [ "get_repository" @@ -75,6 +90,11 @@ "get_tag" ] }, + "GetVPCSCConfig": { + "methods": [ + "get_vpcsc_config" + ] + }, "GetVersion": { "methods": [ "get_version" @@ -100,11 +120,26 @@ "list_files" ] }, + "ListMavenArtifacts": { + "methods": [ + "list_maven_artifacts" + ] + }, + "ListNpmPackages": { + "methods": [ + "list_npm_packages" + ] + }, "ListPackages": { "methods": [ "list_packages" ] }, + "ListPythonPackages": { + "methods": [ + "list_python_packages" + ] + }, "ListRepositories": { "methods": [ "list_repositories" @@ -144,6 +179,11 @@ "methods": [ "update_tag" ] + }, + "UpdateVPCSCConfig": { + "methods": [ + "update_vpcsc_config" + ] } } }, @@ -195,6 +235,16 @@ "get_iam_policy" ] }, + "GetMavenArtifact": { + "methods": [ + "get_maven_artifact" + ] + }, + "GetNpmPackage": { + "methods": [ + "get_npm_package" + ] + }, "GetPackage": { "methods": [ "get_package" @@ -205,6 +255,11 @@ "get_project_settings" ] }, + "GetPythonPackage": { + "methods": [ + "get_python_package" + ] + }, "GetRepository": { "methods": [ "get_repository" @@ -215,6 +270,11 @@ "get_tag" ] }, + "GetVPCSCConfig": { + "methods": [ + "get_vpcsc_config" + ] + }, "GetVersion": { "methods": [ "get_version" @@ -240,11 +300,26 @@ "list_files" ] }, + "ListMavenArtifacts": { + "methods": [ + "list_maven_artifacts" + ] + }, + "ListNpmPackages": { + "methods": [ + "list_npm_packages" + ] + }, "ListPackages": { "methods": [ "list_packages" ] }, + "ListPythonPackages": { + "methods": [ + "list_python_packages" + ] + }, "ListRepositories": { "methods": [ "list_repositories" @@ -284,6 +359,11 @@ "methods": [ "update_tag" ] + }, + "UpdateVPCSCConfig": { + "methods": [ + "update_vpcsc_config" + ] } } } diff --git a/google/cloud/artifactregistry_v1/gapic_version.py b/google/cloud/artifactregistry_v1/gapic_version.py index b4028ab..f033c61 100644 --- a/google/cloud/artifactregistry_v1/gapic_version.py +++ b/google/cloud/artifactregistry_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.1" # {x-release-please-version} +__version__ = "1.7.0" # {x-release-please-version} diff --git a/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py b/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py index 9fc6994..e11ce77 100644 --- a/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py +++ b/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py @@ -47,6 +47,7 @@ from google.cloud.location import locations_pb2 # 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 from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -54,12 +55,15 @@ from google.cloud.artifactregistry_v1.services.artifact_registry import pagers from google.cloud.artifactregistry_v1.types import apt_artifact, artifact, file, package +from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config from google.cloud.artifactregistry_v1.types import repository from google.cloud.artifactregistry_v1.types import repository as gda_repository from google.cloud.artifactregistry_v1.types import service, settings from google.cloud.artifactregistry_v1.types import tag from google.cloud.artifactregistry_v1.types import tag as gda_tag -from google.cloud.artifactregistry_v1.types import version, yum_artifact +from google.cloud.artifactregistry_v1.types import version +from google.cloud.artifactregistry_v1.types import vpcsc_config +from google.cloud.artifactregistry_v1.types import yum_artifact from .client import ArtifactRegistryClient from .transports.base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport @@ -97,16 +101,32 @@ class ArtifactRegistryAsyncClient: ) file_path = staticmethod(ArtifactRegistryClient.file_path) parse_file_path = staticmethod(ArtifactRegistryClient.parse_file_path) + maven_artifact_path = staticmethod(ArtifactRegistryClient.maven_artifact_path) + parse_maven_artifact_path = staticmethod( + ArtifactRegistryClient.parse_maven_artifact_path + ) + npm_package_path = staticmethod(ArtifactRegistryClient.npm_package_path) + parse_npm_package_path = staticmethod(ArtifactRegistryClient.parse_npm_package_path) + package_path = staticmethod(ArtifactRegistryClient.package_path) + parse_package_path = staticmethod(ArtifactRegistryClient.parse_package_path) project_settings_path = staticmethod(ArtifactRegistryClient.project_settings_path) parse_project_settings_path = staticmethod( ArtifactRegistryClient.parse_project_settings_path ) + python_package_path = staticmethod(ArtifactRegistryClient.python_package_path) + parse_python_package_path = staticmethod( + ArtifactRegistryClient.parse_python_package_path + ) repository_path = staticmethod(ArtifactRegistryClient.repository_path) parse_repository_path = staticmethod(ArtifactRegistryClient.parse_repository_path) tag_path = staticmethod(ArtifactRegistryClient.tag_path) parse_tag_path = staticmethod(ArtifactRegistryClient.parse_tag_path) version_path = staticmethod(ArtifactRegistryClient.version_path) parse_version_path = staticmethod(ArtifactRegistryClient.parse_version_path) + vpcsc_config_path = staticmethod(ArtifactRegistryClient.vpcsc_config_path) + parse_vpcsc_config_path = staticmethod( + ArtifactRegistryClient.parse_vpcsc_config_path + ) yum_artifact_path = staticmethod(ArtifactRegistryClient.yum_artifact_path) parse_yum_artifact_path = staticmethod( ArtifactRegistryClient.parse_yum_artifact_path @@ -273,8 +293,659 @@ async def list_docker_images( retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListDockerImagesAsyncPager: - r"""Lists docker images. + ) -> pagers.ListDockerImagesAsyncPager: + r"""Lists docker images. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + async def sample_list_docker_images(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListDockerImagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_docker_images(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.ListDockerImagesRequest, dict]]): + The request object. The request to list docker images. + parent (:class:`str`): + Required. The name of the parent + resource whose docker images will be + listed. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesAsyncPager: + The response from listing docker + images. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = artifact.ListDockerImagesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_docker_images, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListDockerImagesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_docker_image( + self, + request: Optional[Union[artifact.GetDockerImageRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> artifact.DockerImage: + r"""Gets a docker image. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + async def sample_get_docker_image(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetDockerImageRequest( + name="name_value", + ) + + # Make the request + response = await client.get_docker_image(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetDockerImageRequest, dict]]): + The request object. The request to get docker images. + name (:class:`str`): + Required. The name of the docker + images. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.DockerImage: + DockerImage represents a docker artifact. + The following fields are returned as untyped metadata + in the Version resource, using camelcase keys (i.e. + metadata.imageSizeBytes): \* imageSizeBytes \* + mediaType \* buildTime + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = artifact.GetDockerImageRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_docker_image, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_maven_artifacts( + self, + request: Optional[Union[artifact.ListMavenArtifactsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMavenArtifactsAsyncPager: + r"""Lists maven artifacts. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + async def sample_list_maven_artifacts(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListMavenArtifactsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_maven_artifacts(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.ListMavenArtifactsRequest, dict]]): + The request object. The request to list maven artifacts. + parent (:class:`str`): + Required. The name of the parent + resource whose maven artifacts will be + listed. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsAsyncPager: + The response from listing maven + artifacts. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = artifact.ListMavenArtifactsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_maven_artifacts, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListMavenArtifactsAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_maven_artifact( + self, + request: Optional[Union[artifact.GetMavenArtifactRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> artifact.MavenArtifact: + r"""Gets a maven artifact. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + async def sample_get_maven_artifact(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetMavenArtifactRequest( + name="name_value", + ) + + # Make the request + response = await client.get_maven_artifact(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest, dict]]): + The request object. The request to get maven artifacts. + name (:class:`str`): + Required. The name of the maven + artifact. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.MavenArtifact: + MavenArtifact represents a maven + artifact. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = artifact.GetMavenArtifactRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_maven_artifact, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_npm_packages( + self, + request: Optional[Union[artifact.ListNpmPackagesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListNpmPackagesAsyncPager: + r"""Lists npm packages. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + async def sample_list_npm_packages(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListNpmPackagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_npm_packages(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest, dict]]): + The request object. The request to list npm packages. + parent (:class:`str`): + Required. The name of the parent + resource whose npm packages will be + listed. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesAsyncPager: + The response from listing npm + packages. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = artifact.ListNpmPackagesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_npm_packages, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListNpmPackagesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_npm_package( + self, + request: Optional[Union[artifact.GetNpmPackageRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> artifact.NpmPackage: + r"""Gets a npm package. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + async def sample_get_npm_package(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetNpmPackageRequest( + name="name_value", + ) + + # Make the request + response = await client.get_npm_package(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetNpmPackageRequest, dict]]): + The request object. The request to get npm packages. + name (:class:`str`): + Required. The name of the npm + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.NpmPackage: + NpmPackage represents an npm + artifact. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = artifact.GetNpmPackageRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_npm_package, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_python_packages( + self, + request: Optional[Union[artifact.ListPythonPackagesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPythonPackagesAsyncPager: + r"""Lists python packages. .. code-block:: python @@ -287,28 +958,28 @@ async def list_docker_images( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_list_docker_images(): + async def sample_list_python_packages(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.ListDockerImagesRequest( + request = artifactregistry_v1.ListPythonPackagesRequest( parent="parent_value", ) # Make the request - page_result = client.list_docker_images(request=request) + page_result = client.list_python_packages(request=request) # Handle the response async for response in page_result: print(response) Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListDockerImagesRequest, dict]]): - The request object. The request to list docker images. + request (Optional[Union[google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest, dict]]): + The request object. The request to list python packages. parent (:class:`str`): Required. The name of the parent - resource whose docker images will be + resource whose python packages will be listed. This corresponds to the ``parent`` field @@ -321,9 +992,9 @@ async def sample_list_docker_images(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesAsyncPager: - The response from listing docker - images. + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesAsyncPager: + The response from listing python + packages. Iterating over this object will yield results and resolve additional pages automatically. @@ -339,7 +1010,7 @@ async def sample_list_docker_images(): "the individual field arguments should be set." ) - request = artifact.ListDockerImagesRequest(request) + request = artifact.ListPythonPackagesRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. @@ -349,7 +1020,7 @@ async def sample_list_docker_images(): # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method_async.wrap_method( - self._client._transport.list_docker_images, + self._client._transport.list_python_packages, default_timeout=None, client_info=DEFAULT_CLIENT_INFO, ) @@ -370,7 +1041,7 @@ async def sample_list_docker_images(): # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. - response = pagers.ListDockerImagesAsyncPager( + response = pagers.ListPythonPackagesAsyncPager( method=rpc, request=request, response=response, @@ -380,16 +1051,16 @@ async def sample_list_docker_images(): # Done; return the response. return response - async def get_docker_image( + async def get_python_package( self, - request: Optional[Union[artifact.GetDockerImageRequest, dict]] = None, + request: Optional[Union[artifact.GetPythonPackageRequest, dict]] = None, *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> artifact.DockerImage: - r"""Gets a docker image. + ) -> artifact.PythonPackage: + r"""Gets a python package. .. code-block:: python @@ -402,27 +1073,27 @@ async def get_docker_image( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_get_docker_image(): + async def sample_get_python_package(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.GetDockerImageRequest( + request = artifactregistry_v1.GetPythonPackageRequest( name="name_value", ) # Make the request - response = await client.get_docker_image(request=request) + response = await client.get_python_package(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetDockerImageRequest, dict]]): - The request object. The request to get docker images. + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetPythonPackageRequest, dict]]): + The request object. The request to get python packages. name (:class:`str`): - Required. The name of the docker - images. + Required. The name of the python + package. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -434,12 +1105,9 @@ async def sample_get_docker_image(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.DockerImage: - DockerImage represents a docker artifact. - The following fields are returned as untyped metadata - in the Version resource, using camelcase keys (i.e. - metadata.imageSizeBytes): \* imageSizeBytes \* - mediaType \* buildTime + google.cloud.artifactregistry_v1.types.PythonPackage: + PythonPackage represents a python + artifact. """ # Create or coerce a protobuf request object. @@ -452,7 +1120,7 @@ async def sample_get_docker_image(): "the individual field arguments should be set." ) - request = artifact.GetDockerImageRequest(request) + request = artifact.GetPythonPackageRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. @@ -462,7 +1130,7 @@ async def sample_get_docker_image(): # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method_async.wrap_method( - self._client._transport.get_docker_image, + self._client._transport.get_python_package, default_timeout=None, client_info=DEFAULT_CLIENT_INFO, ) @@ -1977,6 +2645,7 @@ async def sample_list_files(): # Initialize request argument(s) request = artifactregistry_v1.ListFilesRequest( + parent="parent_value", ) # Make the request @@ -1990,8 +2659,8 @@ async def sample_list_files(): request (Optional[Union[google.cloud.artifactregistry_v1.types.ListFilesRequest, dict]]): The request object. The request to list files. parent (:class:`str`): - The name of the repository whose - files will be listed. For example: + Required. The name of the repository + whose files will be listed. For example: "projects/p1/locations/us-central1/repositories/repo1 This corresponds to the ``parent`` field @@ -2090,6 +2759,7 @@ async def sample_get_file(): # Initialize request argument(s) request = artifactregistry_v1.GetFileRequest( + name="name_value", ) # Make the request @@ -2102,7 +2772,9 @@ async def sample_get_file(): request (Optional[Union[google.cloud.artifactregistry_v1.types.GetFileRequest, dict]]): The request object. The request to retrieve a file. name (:class:`str`): - The name of the file to retrieve. + Required. The name of the file to + retrieve. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -3272,6 +3944,275 @@ async def sample_update_project_settings(): # Done; return the response. return response + async def get_vpcsc_config( + self, + request: Optional[Union[vpcsc_config.GetVPCSCConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> vpcsc_config.VPCSCConfig: + r"""Retrieves the VPCSC Config for the Project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + async def sample_get_vpcsc_config(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetVPCSCConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vpcsc_config(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetVPCSCConfigRequest, dict]]): + The request object. Gets the VPC SC config for a + project. + name (:class:`str`): + Required. The name of the VPCSCConfig + resource. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.VPCSCConfig: + The Artifact Registry VPC SC config + that apply to a Project. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vpcsc_config.GetVPCSCConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_vpcsc_config, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_vpcsc_config( + self, + request: Optional[ + Union[gda_vpcsc_config.UpdateVPCSCConfigRequest, dict] + ] = None, + *, + vpcsc_config: Optional[gda_vpcsc_config.VPCSCConfig] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gda_vpcsc_config.VPCSCConfig: + r"""Updates the VPCSC Config for the Project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + async def sample_update_vpcsc_config(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateVPCSCConfigRequest( + ) + + # Make the request + response = await client.update_vpcsc_config(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateVPCSCConfigRequest, dict]]): + The request object. Sets the VPCSC config of the + project. + vpcsc_config (:class:`google.cloud.artifactregistry_v1.types.VPCSCConfig`): + The project config. + This corresponds to the ``vpcsc_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Field mask to support partial + updates. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.VPCSCConfig: + The Artifact Registry VPC SC config + that apply to a Project. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([vpcsc_config, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = gda_vpcsc_config.UpdateVPCSCConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if vpcsc_config is not None: + request.vpcsc_config = vpcsc_config + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_vpcsc_config, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("vpcsc_config.name", request.vpcsc_config.name),) + ), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_operation( + self, + request: Optional[operations_pb2.GetOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # 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 = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._client._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def get_location( self, request: Optional[locations_pb2.GetLocationRequest] = None, diff --git a/google/cloud/artifactregistry_v1/services/artifact_registry/client.py b/google/cloud/artifactregistry_v1/services/artifact_registry/client.py index d50d22c..88d79b6 100644 --- a/google/cloud/artifactregistry_v1/services/artifact_registry/client.py +++ b/google/cloud/artifactregistry_v1/services/artifact_registry/client.py @@ -51,6 +51,7 @@ from google.cloud.location import locations_pb2 # 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 from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -58,12 +59,15 @@ from google.cloud.artifactregistry_v1.services.artifact_registry import pagers from google.cloud.artifactregistry_v1.types import apt_artifact, artifact, file, package +from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config from google.cloud.artifactregistry_v1.types import repository from google.cloud.artifactregistry_v1.types import repository as gda_repository from google.cloud.artifactregistry_v1.types import service, settings from google.cloud.artifactregistry_v1.types import tag from google.cloud.artifactregistry_v1.types import tag as gda_tag -from google.cloud.artifactregistry_v1.types import version, yum_artifact +from google.cloud.artifactregistry_v1.types import version +from google.cloud.artifactregistry_v1.types import vpcsc_config +from google.cloud.artifactregistry_v1.types import yum_artifact from .transports.base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport from .transports.grpc import ArtifactRegistryGrpcTransport @@ -276,6 +280,78 @@ def parse_file_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def maven_artifact_path( + project: str, + location: str, + repository: str, + maven_artifact: str, + ) -> str: + """Returns a fully-qualified maven_artifact string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/mavenArtifacts/{maven_artifact}".format( + project=project, + location=location, + repository=repository, + maven_artifact=maven_artifact, + ) + + @staticmethod + def parse_maven_artifact_path(path: str) -> Dict[str, str]: + """Parses a maven_artifact path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/mavenArtifacts/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def npm_package_path( + project: str, + location: str, + repository: str, + npm_package: str, + ) -> str: + """Returns a fully-qualified npm_package string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/npmPackages/{npm_package}".format( + project=project, + location=location, + repository=repository, + npm_package=npm_package, + ) + + @staticmethod + def parse_npm_package_path(path: str) -> Dict[str, str]: + """Parses a npm_package path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/npmPackages/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def package_path( + project: str, + location: str, + repository: str, + package: str, + ) -> str: + """Returns a fully-qualified package string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}".format( + project=project, + location=location, + repository=repository, + package=package, + ) + + @staticmethod + def parse_package_path(path: str) -> Dict[str, str]: + """Parses a package path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/packages/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def project_settings_path( project: str, @@ -291,6 +367,30 @@ def parse_project_settings_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/projectSettings$", path) return m.groupdict() if m else {} + @staticmethod + def python_package_path( + project: str, + location: str, + repository: str, + python_package: str, + ) -> str: + """Returns a fully-qualified python_package string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/pythonPackages/{python_package}".format( + project=project, + location=location, + repository=repository, + python_package=python_package, + ) + + @staticmethod + def parse_python_package_path(path: str) -> Dict[str, str]: + """Parses a python_package path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/pythonPackages/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def repository_path( project: str, @@ -367,6 +467,25 @@ def parse_version_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def vpcsc_config_path( + project: str, + location: str, + ) -> str: + """Returns a fully-qualified vpcsc_config string.""" + return "projects/{project}/locations/{location}/vpcscConfig".format( + project=project, + location=location, + ) + + @staticmethod + def parse_vpcsc_config_path(path: str) -> Dict[str, str]: + """Parses a vpcsc_config path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/vpcscConfig$", path + ) + return m.groupdict() if m else {} + @staticmethod def yum_artifact_path( project: str, @@ -643,8 +762,659 @@ def list_docker_images( retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListDockerImagesPager: - r"""Lists docker images. + ) -> pagers.ListDockerImagesPager: + r"""Lists docker images. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + def sample_list_docker_images(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListDockerImagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_docker_images(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.ListDockerImagesRequest, dict]): + The request object. The request to list docker images. + parent (str): + Required. The name of the parent + resource whose docker images will be + listed. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesPager: + The response from listing docker + images. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a artifact.ListDockerImagesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, artifact.ListDockerImagesRequest): + request = artifact.ListDockerImagesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_docker_images] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListDockerImagesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_docker_image( + self, + request: Optional[Union[artifact.GetDockerImageRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> artifact.DockerImage: + r"""Gets a docker image. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + def sample_get_docker_image(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetDockerImageRequest( + name="name_value", + ) + + # Make the request + response = client.get_docker_image(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.GetDockerImageRequest, dict]): + The request object. The request to get docker images. + name (str): + Required. The name of the docker + images. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.DockerImage: + DockerImage represents a docker artifact. + The following fields are returned as untyped metadata + in the Version resource, using camelcase keys (i.e. + metadata.imageSizeBytes): \* imageSizeBytes \* + mediaType \* buildTime + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a artifact.GetDockerImageRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, artifact.GetDockerImageRequest): + request = artifact.GetDockerImageRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_docker_image] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_maven_artifacts( + self, + request: Optional[Union[artifact.ListMavenArtifactsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListMavenArtifactsPager: + r"""Lists maven artifacts. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + def sample_list_maven_artifacts(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListMavenArtifactsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_maven_artifacts(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.ListMavenArtifactsRequest, dict]): + The request object. The request to list maven artifacts. + parent (str): + Required. The name of the parent + resource whose maven artifacts will be + listed. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsPager: + The response from listing maven + artifacts. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a artifact.ListMavenArtifactsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, artifact.ListMavenArtifactsRequest): + request = artifact.ListMavenArtifactsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_maven_artifacts] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListMavenArtifactsPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_maven_artifact( + self, + request: Optional[Union[artifact.GetMavenArtifactRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> artifact.MavenArtifact: + r"""Gets a maven artifact. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + def sample_get_maven_artifact(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetMavenArtifactRequest( + name="name_value", + ) + + # Make the request + response = client.get_maven_artifact(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest, dict]): + The request object. The request to get maven artifacts. + name (str): + Required. The name of the maven + artifact. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.MavenArtifact: + MavenArtifact represents a maven + artifact. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a artifact.GetMavenArtifactRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, artifact.GetMavenArtifactRequest): + request = artifact.GetMavenArtifactRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_maven_artifact] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_npm_packages( + self, + request: Optional[Union[artifact.ListNpmPackagesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListNpmPackagesPager: + r"""Lists npm packages. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + def sample_list_npm_packages(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListNpmPackagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_npm_packages(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest, dict]): + The request object. The request to list npm packages. + parent (str): + Required. The name of the parent + resource whose npm packages will be + listed. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesPager: + The response from listing npm + packages. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a artifact.ListNpmPackagesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, artifact.ListNpmPackagesRequest): + request = artifact.ListNpmPackagesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_npm_packages] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListNpmPackagesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_npm_package( + self, + request: Optional[Union[artifact.GetNpmPackageRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> artifact.NpmPackage: + r"""Gets a npm package. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + def sample_get_npm_package(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetNpmPackageRequest( + name="name_value", + ) + + # Make the request + response = client.get_npm_package(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.GetNpmPackageRequest, dict]): + The request object. The request to get npm packages. + name (str): + Required. The name of the npm + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.NpmPackage: + NpmPackage represents an npm + artifact. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a artifact.GetNpmPackageRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, artifact.GetNpmPackageRequest): + request = artifact.GetNpmPackageRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_npm_package] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_python_packages( + self, + request: Optional[Union[artifact.ListPythonPackagesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListPythonPackagesPager: + r"""Lists python packages. .. code-block:: python @@ -657,28 +1427,28 @@ def list_docker_images( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_list_docker_images(): + def sample_list_python_packages(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.ListDockerImagesRequest( + request = artifactregistry_v1.ListPythonPackagesRequest( parent="parent_value", ) # Make the request - page_result = client.list_docker_images(request=request) + page_result = client.list_python_packages(request=request) # Handle the response for response in page_result: print(response) Args: - request (Union[google.cloud.artifactregistry_v1.types.ListDockerImagesRequest, dict]): - The request object. The request to list docker images. + request (Union[google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest, dict]): + The request object. The request to list python packages. parent (str): Required. The name of the parent - resource whose docker images will be + resource whose python packages will be listed. This corresponds to the ``parent`` field @@ -691,9 +1461,9 @@ def sample_list_docker_images(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesPager: - The response from listing docker - images. + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesPager: + The response from listing python + packages. Iterating over this object will yield results and resolve additional pages automatically. @@ -710,11 +1480,11 @@ def sample_list_docker_images(): ) # Minor optimization to avoid making a copy if the user passes - # in a artifact.ListDockerImagesRequest. + # in a artifact.ListPythonPackagesRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. - if not isinstance(request, artifact.ListDockerImagesRequest): - request = artifact.ListDockerImagesRequest(request) + if not isinstance(request, artifact.ListPythonPackagesRequest): + request = artifact.ListPythonPackagesRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: @@ -722,7 +1492,7 @@ def sample_list_docker_images(): # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_docker_images] + rpc = self._transport._wrapped_methods[self._transport.list_python_packages] # Certain fields should be provided within the metadata header; # add these here. @@ -740,7 +1510,7 @@ def sample_list_docker_images(): # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. - response = pagers.ListDockerImagesPager( + response = pagers.ListPythonPackagesPager( method=rpc, request=request, response=response, @@ -750,16 +1520,16 @@ def sample_list_docker_images(): # Done; return the response. return response - def get_docker_image( + def get_python_package( self, - request: Optional[Union[artifact.GetDockerImageRequest, dict]] = None, + request: Optional[Union[artifact.GetPythonPackageRequest, dict]] = None, *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> artifact.DockerImage: - r"""Gets a docker image. + ) -> artifact.PythonPackage: + r"""Gets a python package. .. code-block:: python @@ -772,27 +1542,27 @@ def get_docker_image( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_get_docker_image(): + def sample_get_python_package(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.GetDockerImageRequest( + request = artifactregistry_v1.GetPythonPackageRequest( name="name_value", ) # Make the request - response = client.get_docker_image(request=request) + response = client.get_python_package(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.artifactregistry_v1.types.GetDockerImageRequest, dict]): - The request object. The request to get docker images. + request (Union[google.cloud.artifactregistry_v1.types.GetPythonPackageRequest, dict]): + The request object. The request to get python packages. name (str): - Required. The name of the docker - images. + Required. The name of the python + package. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -804,12 +1574,9 @@ def sample_get_docker_image(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.DockerImage: - DockerImage represents a docker artifact. - The following fields are returned as untyped metadata - in the Version resource, using camelcase keys (i.e. - metadata.imageSizeBytes): \* imageSizeBytes \* - mediaType \* buildTime + google.cloud.artifactregistry_v1.types.PythonPackage: + PythonPackage represents a python + artifact. """ # Create or coerce a protobuf request object. @@ -823,11 +1590,11 @@ def sample_get_docker_image(): ) # Minor optimization to avoid making a copy if the user passes - # in a artifact.GetDockerImageRequest. + # in a artifact.GetPythonPackageRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. - if not isinstance(request, artifact.GetDockerImageRequest): - request = artifact.GetDockerImageRequest(request) + if not isinstance(request, artifact.GetPythonPackageRequest): + request = artifact.GetPythonPackageRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if name is not None: @@ -835,7 +1602,7 @@ def sample_get_docker_image(): # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_docker_image] + rpc = self._transport._wrapped_methods[self._transport.get_python_package] # Certain fields should be provided within the metadata header; # add these here. @@ -2349,6 +3116,7 @@ def sample_list_files(): # Initialize request argument(s) request = artifactregistry_v1.ListFilesRequest( + parent="parent_value", ) # Make the request @@ -2362,8 +3130,8 @@ def sample_list_files(): request (Union[google.cloud.artifactregistry_v1.types.ListFilesRequest, dict]): The request object. The request to list files. parent (str): - The name of the repository whose - files will be listed. For example: + Required. The name of the repository + whose files will be listed. For example: "projects/p1/locations/us-central1/repositories/repo1 This corresponds to the ``parent`` field @@ -2462,6 +3230,7 @@ def sample_get_file(): # Initialize request argument(s) request = artifactregistry_v1.GetFileRequest( + name="name_value", ) # Make the request @@ -2474,7 +3243,9 @@ def sample_get_file(): request (Union[google.cloud.artifactregistry_v1.types.GetFileRequest, dict]): The request object. The request to retrieve a file. name (str): - The name of the file to retrieve. + Required. The name of the file to + retrieve. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -3641,6 +4412,221 @@ def sample_update_project_settings(): # Done; return the response. return response + def get_vpcsc_config( + self, + request: Optional[Union[vpcsc_config.GetVPCSCConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> vpcsc_config.VPCSCConfig: + r"""Retrieves the VPCSC Config for the Project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + def sample_get_vpcsc_config(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetVPCSCConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_vpcsc_config(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.GetVPCSCConfigRequest, dict]): + The request object. Gets the VPC SC config for a + project. + name (str): + Required. The name of the VPCSCConfig + resource. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.VPCSCConfig: + The Artifact Registry VPC SC config + that apply to a Project. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vpcsc_config.GetVPCSCConfigRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vpcsc_config.GetVPCSCConfigRequest): + request = vpcsc_config.GetVPCSCConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_vpcsc_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_vpcsc_config( + self, + request: Optional[ + Union[gda_vpcsc_config.UpdateVPCSCConfigRequest, dict] + ] = None, + *, + vpcsc_config: Optional[gda_vpcsc_config.VPCSCConfig] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gda_vpcsc_config.VPCSCConfig: + r"""Updates the VPCSC Config for the Project. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import artifactregistry_v1 + + def sample_update_vpcsc_config(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateVPCSCConfigRequest( + ) + + # Make the request + response = client.update_vpcsc_config(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.UpdateVPCSCConfigRequest, dict]): + The request object. Sets the VPCSC config of the + project. + vpcsc_config (google.cloud.artifactregistry_v1.types.VPCSCConfig): + The project config. + This corresponds to the ``vpcsc_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Field mask to support partial + updates. + + 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. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.artifactregistry_v1.types.VPCSCConfig: + The Artifact Registry VPC SC config + that apply to a Project. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([vpcsc_config, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a gda_vpcsc_config.UpdateVPCSCConfigRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, gda_vpcsc_config.UpdateVPCSCConfigRequest): + request = gda_vpcsc_config.UpdateVPCSCConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if vpcsc_config is not None: + request.vpcsc_config = vpcsc_config + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_vpcsc_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("vpcsc_config.name", request.vpcsc_config.name),) + ), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def __enter__(self) -> "ArtifactRegistryClient": return self @@ -3654,6 +4640,60 @@ def __exit__(self, type, value, traceback): """ self.transport.close() + def get_operation( + self, + request: Optional[operations_pb2.GetOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Gets the latest state of a long-running operation. + + Args: + request (:class:`~.operations_pb2.GetOperationRequest`): + The request object. Request message for + `GetOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + Returns: + ~.operations_pb2.Operation: + An ``Operation`` object. + """ + # 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 = operations_pb2.GetOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_operation, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def get_location( self, request: Optional[locations_pb2.GetLocationRequest] = None, diff --git a/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py b/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py index 8c46275..b484b70 100644 --- a/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py +++ b/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py @@ -162,6 +162,390 @@ def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) +class ListMavenArtifactsPager: + """A pager for iterating through ``list_maven_artifacts`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListMavenArtifactsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``maven_artifacts`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListMavenArtifacts`` requests and continue to iterate + through the ``maven_artifacts`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListMavenArtifactsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., artifact.ListMavenArtifactsResponse], + request: artifact.ListMavenArtifactsRequest, + response: artifact.ListMavenArtifactsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.artifactregistry_v1.types.ListMavenArtifactsRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListMavenArtifactsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = artifact.ListMavenArtifactsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[artifact.ListMavenArtifactsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[artifact.MavenArtifact]: + for page in self.pages: + yield from page.maven_artifacts + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListMavenArtifactsAsyncPager: + """A pager for iterating through ``list_maven_artifacts`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListMavenArtifactsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``maven_artifacts`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListMavenArtifacts`` requests and continue to iterate + through the ``maven_artifacts`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListMavenArtifactsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[artifact.ListMavenArtifactsResponse]], + request: artifact.ListMavenArtifactsRequest, + response: artifact.ListMavenArtifactsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.artifactregistry_v1.types.ListMavenArtifactsRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListMavenArtifactsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = artifact.ListMavenArtifactsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[artifact.ListMavenArtifactsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[artifact.MavenArtifact]: + async def async_generator(): + async for page in self.pages: + for response in page.maven_artifacts: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListNpmPackagesPager: + """A pager for iterating through ``list_npm_packages`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListNpmPackagesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``npm_packages`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListNpmPackages`` requests and continue to iterate + through the ``npm_packages`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListNpmPackagesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., artifact.ListNpmPackagesResponse], + request: artifact.ListNpmPackagesRequest, + response: artifact.ListNpmPackagesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListNpmPackagesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = artifact.ListNpmPackagesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[artifact.ListNpmPackagesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[artifact.NpmPackage]: + for page in self.pages: + yield from page.npm_packages + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListNpmPackagesAsyncPager: + """A pager for iterating through ``list_npm_packages`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListNpmPackagesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``npm_packages`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListNpmPackages`` requests and continue to iterate + through the ``npm_packages`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListNpmPackagesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[artifact.ListNpmPackagesResponse]], + request: artifact.ListNpmPackagesRequest, + response: artifact.ListNpmPackagesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListNpmPackagesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = artifact.ListNpmPackagesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[artifact.ListNpmPackagesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[artifact.NpmPackage]: + async def async_generator(): + async for page in self.pages: + for response in page.npm_packages: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListPythonPackagesPager: + """A pager for iterating through ``list_python_packages`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListPythonPackagesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``python_packages`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPythonPackages`` requests and continue to iterate + through the ``python_packages`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListPythonPackagesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., artifact.ListPythonPackagesResponse], + request: artifact.ListPythonPackagesRequest, + response: artifact.ListPythonPackagesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListPythonPackagesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = artifact.ListPythonPackagesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[artifact.ListPythonPackagesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[artifact.PythonPackage]: + for page in self.pages: + yield from page.python_packages + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListPythonPackagesAsyncPager: + """A pager for iterating through ``list_python_packages`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListPythonPackagesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``python_packages`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPythonPackages`` requests and continue to iterate + through the ``python_packages`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListPythonPackagesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[artifact.ListPythonPackagesResponse]], + request: artifact.ListPythonPackagesRequest, + response: artifact.ListPythonPackagesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListPythonPackagesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = artifact.ListPythonPackagesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[artifact.ListPythonPackagesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[artifact.PythonPackage]: + async def async_generator(): + async for page in self.pages: + for response in page.python_packages: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListRepositoriesPager: """A pager for iterating through ``list_repositories`` requests. diff --git a/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py b/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py index 61980c4..508ce62 100644 --- a/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py +++ b/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py @@ -31,12 +31,15 @@ from google.cloud.artifactregistry_v1 import gapic_version as package_version from google.cloud.artifactregistry_v1.types import apt_artifact, artifact, file, package +from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config from google.cloud.artifactregistry_v1.types import repository from google.cloud.artifactregistry_v1.types import repository as gda_repository from google.cloud.artifactregistry_v1.types import settings from google.cloud.artifactregistry_v1.types import tag from google.cloud.artifactregistry_v1.types import tag as gda_tag -from google.cloud.artifactregistry_v1.types import version, yum_artifact +from google.cloud.artifactregistry_v1.types import version +from google.cloud.artifactregistry_v1.types import vpcsc_config +from google.cloud.artifactregistry_v1.types import yum_artifact DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=package_version.__version__ @@ -146,6 +149,36 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.list_maven_artifacts: gapic_v1.method.wrap_method( + self.list_maven_artifacts, + default_timeout=None, + client_info=client_info, + ), + self.get_maven_artifact: gapic_v1.method.wrap_method( + self.get_maven_artifact, + default_timeout=None, + client_info=client_info, + ), + self.list_npm_packages: gapic_v1.method.wrap_method( + self.list_npm_packages, + default_timeout=None, + client_info=client_info, + ), + self.get_npm_package: gapic_v1.method.wrap_method( + self.get_npm_package, + default_timeout=None, + client_info=client_info, + ), + self.list_python_packages: gapic_v1.method.wrap_method( + self.list_python_packages, + default_timeout=None, + client_info=client_info, + ), + self.get_python_package: gapic_v1.method.wrap_method( + self.get_python_package, + default_timeout=None, + client_info=client_info, + ), self.import_apt_artifacts: gapic_v1.method.wrap_method( self.import_apt_artifacts, default_timeout=None, @@ -271,6 +304,16 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.get_vpcsc_config: gapic_v1.method.wrap_method( + self.get_vpcsc_config, + default_timeout=None, + client_info=client_info, + ), + self.update_vpcsc_config: gapic_v1.method.wrap_method( + self.update_vpcsc_config, + default_timeout=None, + client_info=client_info, + ), } def close(self): @@ -308,6 +351,69 @@ def get_docker_image( ]: raise NotImplementedError() + @property + def list_maven_artifacts( + self, + ) -> Callable[ + [artifact.ListMavenArtifactsRequest], + Union[ + artifact.ListMavenArtifactsResponse, + Awaitable[artifact.ListMavenArtifactsResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_maven_artifact( + self, + ) -> Callable[ + [artifact.GetMavenArtifactRequest], + Union[artifact.MavenArtifact, Awaitable[artifact.MavenArtifact]], + ]: + raise NotImplementedError() + + @property + def list_npm_packages( + self, + ) -> Callable[ + [artifact.ListNpmPackagesRequest], + Union[ + artifact.ListNpmPackagesResponse, + Awaitable[artifact.ListNpmPackagesResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_npm_package( + self, + ) -> Callable[ + [artifact.GetNpmPackageRequest], + Union[artifact.NpmPackage, Awaitable[artifact.NpmPackage]], + ]: + raise NotImplementedError() + + @property + def list_python_packages( + self, + ) -> Callable[ + [artifact.ListPythonPackagesRequest], + Union[ + artifact.ListPythonPackagesResponse, + Awaitable[artifact.ListPythonPackagesResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_python_package( + self, + ) -> Callable[ + [artifact.GetPythonPackageRequest], + Union[artifact.PythonPackage, Awaitable[artifact.PythonPackage]], + ]: + raise NotImplementedError() + @property def import_apt_artifacts( self, @@ -528,6 +634,33 @@ def update_project_settings( ]: raise NotImplementedError() + @property + def get_vpcsc_config( + self, + ) -> Callable[ + [vpcsc_config.GetVPCSCConfigRequest], + Union[vpcsc_config.VPCSCConfig, Awaitable[vpcsc_config.VPCSCConfig]], + ]: + raise NotImplementedError() + + @property + def update_vpcsc_config( + self, + ) -> Callable[ + [gda_vpcsc_config.UpdateVPCSCConfigRequest], + Union[gda_vpcsc_config.VPCSCConfig, Awaitable[gda_vpcsc_config.VPCSCConfig]], + ]: + raise NotImplementedError() + + @property + def get_operation( + self, + ) -> Callable[ + [operations_pb2.GetOperationRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def get_location( self, diff --git a/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py b/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py index eae398c..8b8b6ed 100644 --- a/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py +++ b/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py @@ -28,12 +28,15 @@ import grpc # type: ignore from google.cloud.artifactregistry_v1.types import apt_artifact, artifact, file, package +from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config from google.cloud.artifactregistry_v1.types import repository from google.cloud.artifactregistry_v1.types import repository as gda_repository from google.cloud.artifactregistry_v1.types import settings from google.cloud.artifactregistry_v1.types import tag from google.cloud.artifactregistry_v1.types import tag as gda_tag -from google.cloud.artifactregistry_v1.types import version, yum_artifact +from google.cloud.artifactregistry_v1.types import version +from google.cloud.artifactregistry_v1.types import vpcsc_config +from google.cloud.artifactregistry_v1.types import yum_artifact from .base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport @@ -320,6 +323,166 @@ def get_docker_image( ) return self._stubs["get_docker_image"] + @property + def list_maven_artifacts( + self, + ) -> Callable[ + [artifact.ListMavenArtifactsRequest], artifact.ListMavenArtifactsResponse + ]: + r"""Return a callable for the list maven artifacts method over gRPC. + + Lists maven artifacts. + + Returns: + Callable[[~.ListMavenArtifactsRequest], + ~.ListMavenArtifactsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_maven_artifacts" not in self._stubs: + self._stubs["list_maven_artifacts"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListMavenArtifacts", + request_serializer=artifact.ListMavenArtifactsRequest.serialize, + response_deserializer=artifact.ListMavenArtifactsResponse.deserialize, + ) + return self._stubs["list_maven_artifacts"] + + @property + def get_maven_artifact( + self, + ) -> Callable[[artifact.GetMavenArtifactRequest], artifact.MavenArtifact]: + r"""Return a callable for the get maven artifact method over gRPC. + + Gets a maven artifact. + + Returns: + Callable[[~.GetMavenArtifactRequest], + ~.MavenArtifact]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_maven_artifact" not in self._stubs: + self._stubs["get_maven_artifact"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetMavenArtifact", + request_serializer=artifact.GetMavenArtifactRequest.serialize, + response_deserializer=artifact.MavenArtifact.deserialize, + ) + return self._stubs["get_maven_artifact"] + + @property + def list_npm_packages( + self, + ) -> Callable[[artifact.ListNpmPackagesRequest], artifact.ListNpmPackagesResponse]: + r"""Return a callable for the list npm packages method over gRPC. + + Lists npm packages. + + Returns: + Callable[[~.ListNpmPackagesRequest], + ~.ListNpmPackagesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_npm_packages" not in self._stubs: + self._stubs["list_npm_packages"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListNpmPackages", + request_serializer=artifact.ListNpmPackagesRequest.serialize, + response_deserializer=artifact.ListNpmPackagesResponse.deserialize, + ) + return self._stubs["list_npm_packages"] + + @property + def get_npm_package( + self, + ) -> Callable[[artifact.GetNpmPackageRequest], artifact.NpmPackage]: + r"""Return a callable for the get npm package method over gRPC. + + Gets a npm package. + + Returns: + Callable[[~.GetNpmPackageRequest], + ~.NpmPackage]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_npm_package" not in self._stubs: + self._stubs["get_npm_package"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetNpmPackage", + request_serializer=artifact.GetNpmPackageRequest.serialize, + response_deserializer=artifact.NpmPackage.deserialize, + ) + return self._stubs["get_npm_package"] + + @property + def list_python_packages( + self, + ) -> Callable[ + [artifact.ListPythonPackagesRequest], artifact.ListPythonPackagesResponse + ]: + r"""Return a callable for the list python packages method over gRPC. + + Lists python packages. + + Returns: + Callable[[~.ListPythonPackagesRequest], + ~.ListPythonPackagesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_python_packages" not in self._stubs: + self._stubs["list_python_packages"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListPythonPackages", + request_serializer=artifact.ListPythonPackagesRequest.serialize, + response_deserializer=artifact.ListPythonPackagesResponse.deserialize, + ) + return self._stubs["list_python_packages"] + + @property + def get_python_package( + self, + ) -> Callable[[artifact.GetPythonPackageRequest], artifact.PythonPackage]: + r"""Return a callable for the get python package method over gRPC. + + Gets a python package. + + Returns: + Callable[[~.GetPythonPackageRequest], + ~.PythonPackage]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_python_package" not in self._stubs: + self._stubs["get_python_package"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetPythonPackage", + request_serializer=artifact.GetPythonPackageRequest.serialize, + response_deserializer=artifact.PythonPackage.deserialize, + ) + return self._stubs["get_python_package"] + @property def import_apt_artifacts( self, @@ -975,9 +1138,80 @@ def update_project_settings( ) return self._stubs["update_project_settings"] + @property + def get_vpcsc_config( + self, + ) -> Callable[[vpcsc_config.GetVPCSCConfigRequest], vpcsc_config.VPCSCConfig]: + r"""Return a callable for the get vpcsc config method over gRPC. + + Retrieves the VPCSC Config for the Project. + + Returns: + Callable[[~.GetVPCSCConfigRequest], + ~.VPCSCConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_vpcsc_config" not in self._stubs: + self._stubs["get_vpcsc_config"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetVPCSCConfig", + request_serializer=vpcsc_config.GetVPCSCConfigRequest.serialize, + response_deserializer=vpcsc_config.VPCSCConfig.deserialize, + ) + return self._stubs["get_vpcsc_config"] + + @property + def update_vpcsc_config( + self, + ) -> Callable[ + [gda_vpcsc_config.UpdateVPCSCConfigRequest], gda_vpcsc_config.VPCSCConfig + ]: + r"""Return a callable for the update vpcsc config method over gRPC. + + Updates the VPCSC Config for the Project. + + Returns: + Callable[[~.UpdateVPCSCConfigRequest], + ~.VPCSCConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_vpcsc_config" not in self._stubs: + self._stubs["update_vpcsc_config"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVPCSCConfig", + request_serializer=gda_vpcsc_config.UpdateVPCSCConfigRequest.serialize, + response_deserializer=gda_vpcsc_config.VPCSCConfig.deserialize, + ) + return self._stubs["update_vpcsc_config"] + def close(self): self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + @property def list_locations( self, diff --git a/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py b/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py index 72eecb2..54379da 100644 --- a/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py +++ b/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py @@ -28,12 +28,15 @@ from grpc.experimental import aio # type: ignore from google.cloud.artifactregistry_v1.types import apt_artifact, artifact, file, package +from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config from google.cloud.artifactregistry_v1.types import repository from google.cloud.artifactregistry_v1.types import repository as gda_repository from google.cloud.artifactregistry_v1.types import settings from google.cloud.artifactregistry_v1.types import tag from google.cloud.artifactregistry_v1.types import tag as gda_tag -from google.cloud.artifactregistry_v1.types import version, yum_artifact +from google.cloud.artifactregistry_v1.types import version +from google.cloud.artifactregistry_v1.types import vpcsc_config +from google.cloud.artifactregistry_v1.types import yum_artifact from .base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport from .grpc import ArtifactRegistryGrpcTransport @@ -325,6 +328,174 @@ def get_docker_image( ) return self._stubs["get_docker_image"] + @property + def list_maven_artifacts( + self, + ) -> Callable[ + [artifact.ListMavenArtifactsRequest], + Awaitable[artifact.ListMavenArtifactsResponse], + ]: + r"""Return a callable for the list maven artifacts method over gRPC. + + Lists maven artifacts. + + Returns: + Callable[[~.ListMavenArtifactsRequest], + Awaitable[~.ListMavenArtifactsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_maven_artifacts" not in self._stubs: + self._stubs["list_maven_artifacts"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListMavenArtifacts", + request_serializer=artifact.ListMavenArtifactsRequest.serialize, + response_deserializer=artifact.ListMavenArtifactsResponse.deserialize, + ) + return self._stubs["list_maven_artifacts"] + + @property + def get_maven_artifact( + self, + ) -> Callable[ + [artifact.GetMavenArtifactRequest], Awaitable[artifact.MavenArtifact] + ]: + r"""Return a callable for the get maven artifact method over gRPC. + + Gets a maven artifact. + + Returns: + Callable[[~.GetMavenArtifactRequest], + Awaitable[~.MavenArtifact]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_maven_artifact" not in self._stubs: + self._stubs["get_maven_artifact"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetMavenArtifact", + request_serializer=artifact.GetMavenArtifactRequest.serialize, + response_deserializer=artifact.MavenArtifact.deserialize, + ) + return self._stubs["get_maven_artifact"] + + @property + def list_npm_packages( + self, + ) -> Callable[ + [artifact.ListNpmPackagesRequest], Awaitable[artifact.ListNpmPackagesResponse] + ]: + r"""Return a callable for the list npm packages method over gRPC. + + Lists npm packages. + + Returns: + Callable[[~.ListNpmPackagesRequest], + Awaitable[~.ListNpmPackagesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_npm_packages" not in self._stubs: + self._stubs["list_npm_packages"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListNpmPackages", + request_serializer=artifact.ListNpmPackagesRequest.serialize, + response_deserializer=artifact.ListNpmPackagesResponse.deserialize, + ) + return self._stubs["list_npm_packages"] + + @property + def get_npm_package( + self, + ) -> Callable[[artifact.GetNpmPackageRequest], Awaitable[artifact.NpmPackage]]: + r"""Return a callable for the get npm package method over gRPC. + + Gets a npm package. + + Returns: + Callable[[~.GetNpmPackageRequest], + Awaitable[~.NpmPackage]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_npm_package" not in self._stubs: + self._stubs["get_npm_package"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetNpmPackage", + request_serializer=artifact.GetNpmPackageRequest.serialize, + response_deserializer=artifact.NpmPackage.deserialize, + ) + return self._stubs["get_npm_package"] + + @property + def list_python_packages( + self, + ) -> Callable[ + [artifact.ListPythonPackagesRequest], + Awaitable[artifact.ListPythonPackagesResponse], + ]: + r"""Return a callable for the list python packages method over gRPC. + + Lists python packages. + + Returns: + Callable[[~.ListPythonPackagesRequest], + Awaitable[~.ListPythonPackagesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_python_packages" not in self._stubs: + self._stubs["list_python_packages"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListPythonPackages", + request_serializer=artifact.ListPythonPackagesRequest.serialize, + response_deserializer=artifact.ListPythonPackagesResponse.deserialize, + ) + return self._stubs["list_python_packages"] + + @property + def get_python_package( + self, + ) -> Callable[ + [artifact.GetPythonPackageRequest], Awaitable[artifact.PythonPackage] + ]: + r"""Return a callable for the get python package method over gRPC. + + Gets a python package. + + Returns: + Callable[[~.GetPythonPackageRequest], + Awaitable[~.PythonPackage]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_python_package" not in self._stubs: + self._stubs["get_python_package"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetPythonPackage", + request_serializer=artifact.GetPythonPackageRequest.serialize, + response_deserializer=artifact.PythonPackage.deserialize, + ) + return self._stubs["get_python_package"] + @property def import_apt_artifacts( self, @@ -1013,9 +1184,83 @@ def update_project_settings( ) return self._stubs["update_project_settings"] + @property + def get_vpcsc_config( + self, + ) -> Callable[ + [vpcsc_config.GetVPCSCConfigRequest], Awaitable[vpcsc_config.VPCSCConfig] + ]: + r"""Return a callable for the get vpcsc config method over gRPC. + + Retrieves the VPCSC Config for the Project. + + Returns: + Callable[[~.GetVPCSCConfigRequest], + Awaitable[~.VPCSCConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_vpcsc_config" not in self._stubs: + self._stubs["get_vpcsc_config"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetVPCSCConfig", + request_serializer=vpcsc_config.GetVPCSCConfigRequest.serialize, + response_deserializer=vpcsc_config.VPCSCConfig.deserialize, + ) + return self._stubs["get_vpcsc_config"] + + @property + def update_vpcsc_config( + self, + ) -> Callable[ + [gda_vpcsc_config.UpdateVPCSCConfigRequest], + Awaitable[gda_vpcsc_config.VPCSCConfig], + ]: + r"""Return a callable for the update vpcsc config method over gRPC. + + Updates the VPCSC Config for the Project. + + Returns: + Callable[[~.UpdateVPCSCConfigRequest], + Awaitable[~.VPCSCConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_vpcsc_config" not in self._stubs: + self._stubs["update_vpcsc_config"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVPCSCConfig", + request_serializer=gda_vpcsc_config.UpdateVPCSCConfigRequest.serialize, + response_deserializer=gda_vpcsc_config.VPCSCConfig.deserialize, + ) + return self._stubs["update_vpcsc_config"] + def close(self): return self.grpc_channel.close() + @property + def get_operation( + self, + ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: + r"""Return a callable for the get_operation method over gRPC.""" + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_operation" not in self._stubs: + self._stubs["get_operation"] = self.grpc_channel.unary_unary( + "/google.longrunning.Operations/GetOperation", + request_serializer=operations_pb2.GetOperationRequest.SerializeToString, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["get_operation"] + @property def list_locations( self, diff --git a/google/cloud/artifactregistry_v1/types/__init__.py b/google/cloud/artifactregistry_v1/types/__init__.py index e439f7a..484effa 100644 --- a/google/cloud/artifactregistry_v1/types/__init__.py +++ b/google/cloud/artifactregistry_v1/types/__init__.py @@ -24,8 +24,20 @@ from .artifact import ( DockerImage, GetDockerImageRequest, + GetMavenArtifactRequest, + GetNpmPackageRequest, + GetPythonPackageRequest, ListDockerImagesRequest, ListDockerImagesResponse, + ListMavenArtifactsRequest, + ListMavenArtifactsResponse, + ListNpmPackagesRequest, + ListNpmPackagesResponse, + ListPythonPackagesRequest, + ListPythonPackagesResponse, + MavenArtifact, + NpmPackage, + PythonPackage, ) from .file import File, GetFileRequest, Hash, ListFilesRequest, ListFilesResponse from .package import ( @@ -60,6 +72,7 @@ UpdateTagRequest, ) from .version import ( + BatchDeleteVersionsMetadata, DeleteVersionRequest, GetVersionRequest, ListVersionsRequest, @@ -67,6 +80,7 @@ Version, VersionView, ) +from .vpcsc_config import GetVPCSCConfigRequest, UpdateVPCSCConfigRequest, VPCSCConfig from .yum_artifact import ( ImportYumArtifactsErrorInfo, ImportYumArtifactsGcsSource, @@ -85,8 +99,20 @@ "ImportAptArtifactsResponse", "DockerImage", "GetDockerImageRequest", + "GetMavenArtifactRequest", + "GetNpmPackageRequest", + "GetPythonPackageRequest", "ListDockerImagesRequest", "ListDockerImagesResponse", + "ListMavenArtifactsRequest", + "ListMavenArtifactsResponse", + "ListNpmPackagesRequest", + "ListNpmPackagesResponse", + "ListPythonPackagesRequest", + "ListPythonPackagesResponse", + "MavenArtifact", + "NpmPackage", + "PythonPackage", "File", "GetFileRequest", "Hash", @@ -115,12 +141,16 @@ "ListTagsResponse", "Tag", "UpdateTagRequest", + "BatchDeleteVersionsMetadata", "DeleteVersionRequest", "GetVersionRequest", "ListVersionsRequest", "ListVersionsResponse", "Version", "VersionView", + "GetVPCSCConfigRequest", + "UpdateVPCSCConfigRequest", + "VPCSCConfig", "ImportYumArtifactsErrorInfo", "ImportYumArtifactsGcsSource", "ImportYumArtifactsMetadata", diff --git a/google/cloud/artifactregistry_v1/types/artifact.py b/google/cloud/artifactregistry_v1/types/artifact.py index a075336..f48ea9e 100644 --- a/google/cloud/artifactregistry_v1/types/artifact.py +++ b/google/cloud/artifactregistry_v1/types/artifact.py @@ -25,6 +25,18 @@ "ListDockerImagesRequest", "ListDockerImagesResponse", "GetDockerImageRequest", + "MavenArtifact", + "ListMavenArtifactsRequest", + "ListMavenArtifactsResponse", + "GetMavenArtifactRequest", + "NpmPackage", + "ListNpmPackagesRequest", + "ListNpmPackagesResponse", + "GetNpmPackageRequest", + "PythonPackage", + "ListPythonPackagesRequest", + "ListPythonPackagesResponse", + "GetPythonPackageRequest", }, ) @@ -77,6 +89,9 @@ class DockerImage(proto.Message): The build time is returned to the client as an RFC 3339 string, which can be easily used with the JavaScript Date constructor. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the docker image + was last updated. """ name: str = proto.Field( @@ -109,6 +124,11 @@ class DockerImage(proto.Message): number=7, message=timestamp_pb2.Timestamp, ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) class ListDockerImagesRequest(proto.Message): @@ -123,6 +143,8 @@ class ListDockerImagesRequest(proto.Message): page_token (str): The next_page_token value returned from a previous list request, if any. + order_by (str): + The field to order the results by. """ parent: str = proto.Field( @@ -137,6 +159,10 @@ class ListDockerImagesRequest(proto.Message): proto.STRING, number=3, ) + order_by: str = proto.Field( + proto.STRING, + number=4, + ) class ListDockerImagesResponse(proto.Message): @@ -180,4 +206,379 @@ class GetDockerImageRequest(proto.Message): ) +class MavenArtifact(proto.Message): + r"""MavenArtifact represents a maven artifact. + + Attributes: + name (str): + Required. registry_location, project_id, repository_name and + maven_artifact forms a unique artifact For example, + "projects/test-project/locations/us-west4/repositories/test-repo/mavenArtifacts/ + com.google.guava:guava:31.0-jre", where "us-west4" is the + registry_location, "test-project" is the project_id, + "test-repo" is the repository_name and + "com.google.guava:guava:31.0-jre" is the maven artifact. + pom_uri (str): + Required. URL to access the pom file of the + artifact. Example: + us-west4-maven.pkg.dev/test-project/test-repo/com/google/guava/guava/31.0/guava-31.0.pom + group_id (str): + Group ID for the artifact. + Example: + com.google.guava + artifact_id (str): + Artifact ID for the artifact. + version (str): + Version of this artifact. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time the artifact was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time the artifact was updated. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + pom_uri: str = proto.Field( + proto.STRING, + number=2, + ) + group_id: str = proto.Field( + proto.STRING, + number=3, + ) + artifact_id: str = proto.Field( + proto.STRING, + number=4, + ) + version: str = proto.Field( + proto.STRING, + number=5, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + + +class ListMavenArtifactsRequest(proto.Message): + r"""The request to list maven artifacts. + + Attributes: + parent (str): + Required. The name of the parent resource + whose maven artifacts will be listed. + page_size (int): + The maximum number of artifacts to return. + page_token (str): + The next_page_token value returned from a previous list + request, if any. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListMavenArtifactsResponse(proto.Message): + r"""The response from listing maven artifacts. + + Attributes: + maven_artifacts (MutableSequence[google.cloud.artifactregistry_v1.types.MavenArtifact]): + The maven artifacts returned. + next_page_token (str): + The token to retrieve the next page of + artifacts, or empty if there are no more + artifacts to return. + """ + + @property + def raw_page(self): + return self + + maven_artifacts: MutableSequence["MavenArtifact"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="MavenArtifact", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetMavenArtifactRequest(proto.Message): + r"""The request to get maven artifacts. + + Attributes: + name (str): + Required. The name of the maven artifact. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class NpmPackage(proto.Message): + r"""NpmPackage represents an npm artifact. + + Attributes: + name (str): + Required. registry_location, project_id, repository_name and + npm_package forms a unique package For example, + "projects/test-project/locations/us-west4/repositories/test-repo/npmPackages/ + npm_test:1.0.0", where "us-west4" is the registry_location, + "test-project" is the project_id, "test-repo" is the + repository_name and npm_test:1.0.0" is the npm package. + package_name (str): + Package for the artifact. + version (str): + Version of this package. + tags (MutableSequence[str]): + Tags attached to this package. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time the package was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time the package was updated. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + package_name: str = proto.Field( + proto.STRING, + number=3, + ) + version: str = proto.Field( + proto.STRING, + number=4, + ) + tags: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=5, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + + +class ListNpmPackagesRequest(proto.Message): + r"""The request to list npm packages. + + Attributes: + parent (str): + Required. The name of the parent resource + whose npm packages will be listed. + page_size (int): + The maximum number of artifacts to return. + page_token (str): + The next_page_token value returned from a previous list + request, if any. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListNpmPackagesResponse(proto.Message): + r"""The response from listing npm packages. + + Attributes: + npm_packages (MutableSequence[google.cloud.artifactregistry_v1.types.NpmPackage]): + The npm packages returned. + next_page_token (str): + The token to retrieve the next page of + artifacts, or empty if there are no more + artifacts to return. + """ + + @property + def raw_page(self): + return self + + npm_packages: MutableSequence["NpmPackage"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="NpmPackage", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetNpmPackageRequest(proto.Message): + r"""The request to get npm packages. + + Attributes: + name (str): + Required. The name of the npm package. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class PythonPackage(proto.Message): + r"""PythonPackage represents a python artifact. + + Attributes: + name (str): + Required. registry_location, project_id, repository_name and + python_package forms a unique package + name:\ ``projects//locations//repository//pythonPackages/``. + For example, + "projects/test-project/locations/us-west4/repositories/test-repo/pythonPackages/ + python_package:1.0.0", where "us-west4" is the + registry_location, "test-project" is the project_id, + "test-repo" is the repository_name and python_package:1.0.0" + is the python package. + uri (str): + Required. URL to access the package. Example: + us-west4-python.pkg.dev/test-project/test-repo/python_package/file-name-1.0.0.tar.gz + package_name (str): + Package for the artifact. + version (str): + Version of this package. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time the package was created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Time the package was updated. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + uri: str = proto.Field( + proto.STRING, + number=2, + ) + package_name: str = proto.Field( + proto.STRING, + number=3, + ) + version: str = proto.Field( + proto.STRING, + number=4, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + + +class ListPythonPackagesRequest(proto.Message): + r"""The request to list python packages. + + Attributes: + parent (str): + Required. The name of the parent resource + whose python packages will be listed. + page_size (int): + The maximum number of artifacts to return. + page_token (str): + The next_page_token value returned from a previous list + request, if any. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListPythonPackagesResponse(proto.Message): + r"""The response from listing python packages. + + Attributes: + python_packages (MutableSequence[google.cloud.artifactregistry_v1.types.PythonPackage]): + The python packages returned. + next_page_token (str): + The token to retrieve the next page of + artifacts, or empty if there are no more + artifacts to return. + """ + + @property + def raw_page(self): + return self + + python_packages: MutableSequence["PythonPackage"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="PythonPackage", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetPythonPackageRequest(proto.Message): + r"""The request to get python packages. + + Attributes: + name (str): + Required. The name of the python package. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/artifactregistry_v1/types/file.py b/google/cloud/artifactregistry_v1/types/file.py index c35c9a7..4484c31 100644 --- a/google/cloud/artifactregistry_v1/types/file.py +++ b/google/cloud/artifactregistry_v1/types/file.py @@ -81,12 +81,18 @@ class File(proto.Message): hashes (MutableSequence[google.cloud.artifactregistry_v1.types.Hash]): The hashes of the file content. create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the File was created. + Output only. The time when the File was + created. update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the File was last updated. + Output only. The time when the File was last + updated. owner (str): The name of the Package or Version that owns this file, if any. + fetch_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the last attempt + to refresh the file's data was made. Only set + when the repository is remote. """ name: str = proto.Field( @@ -116,6 +122,11 @@ class File(proto.Message): proto.STRING, number=7, ) + fetch_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) class ListFilesRequest(proto.Message): @@ -123,8 +134,8 @@ class ListFilesRequest(proto.Message): Attributes: parent (str): - The name of the repository whose files will - be listed. For example: + Required. The name of the repository whose + files will be listed. For example: "projects/p1/locations/us-central1/repositories/repo1 filter (str): An expression for filtering the results of the request. @@ -203,7 +214,7 @@ class GetFileRequest(proto.Message): Attributes: name (str): - The name of the file to retrieve. + Required. The name of the file to retrieve. """ name: str = proto.Field( diff --git a/google/cloud/artifactregistry_v1/types/version.py b/google/cloud/artifactregistry_v1/types/version.py index 96e6133..46c0cb6 100644 --- a/google/cloud/artifactregistry_v1/types/version.py +++ b/google/cloud/artifactregistry_v1/types/version.py @@ -30,6 +30,7 @@ "ListVersionsResponse", "GetVersionRequest", "DeleteVersionRequest", + "BatchDeleteVersionsMetadata", }, ) @@ -78,9 +79,10 @@ class Version(proto.Message): metadata (google.protobuf.struct_pb2.Struct): Output only. Repository-specific Metadata stored against this version. The fields returned are defined by the - underlying repository-specific resource. Currently, the only - resource in use is + underlying repository-specific resource. Currently, the + resources could be: [DockerImage][google.devtools.artifactregistry.v1.DockerImage] + [MavenArtifact][google.devtools.artifactregistry.v1.MavenArtifact] """ name: str = proto.Field( @@ -227,4 +229,18 @@ class DeleteVersionRequest(proto.Message): ) +class BatchDeleteVersionsMetadata(proto.Message): + r"""The metadata of an LRO from deleting multiple versions. + + Attributes: + failed_versions (MutableSequence[str]): + The versions the operation failed to delete. + """ + + failed_versions: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=2, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/artifactregistry_v1/types/vpcsc_config.py b/google/cloud/artifactregistry_v1/types/vpcsc_config.py new file mode 100644 index 0000000..92b07d5 --- /dev/null +++ b/google/cloud/artifactregistry_v1/types/vpcsc_config.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import MutableMapping, MutableSequence + +from google.protobuf import field_mask_pb2 # type: ignore +import proto # type: ignore + +__protobuf__ = proto.module( + package="google.devtools.artifactregistry.v1", + manifest={ + "VPCSCConfig", + "GetVPCSCConfigRequest", + "UpdateVPCSCConfigRequest", + }, +) + + +class VPCSCConfig(proto.Message): + r"""The Artifact Registry VPC SC config that apply to a Project. + + Attributes: + name (str): + The name of the project's VPC SC Config. + Always of the form: + projects/{projectID}/locations/{location}/vpcscConfig + In update request: never set + In response: always set + vpcsc_policy (google.cloud.artifactregistry_v1.types.VPCSCConfig.VPCSCPolicy): + The project per location VPC SC policy that + defines the VPC SC behavior for the Remote + Repository (Allow/Deny). + """ + + class VPCSCPolicy(proto.Enum): + r"""VPCSCPolicy is the VPC SC policy for project and location. + + Values: + VPCSC_POLICY_UNSPECIFIED (0): + VPCSC_POLICY_UNSPECIFIED - the VPS SC policy is not defined. + When VPS SC policy is not defined - the Service will use the + default behavior (VPCSC_DENY). + DENY (1): + VPCSC_DENY - repository will block the requests to the + Upstreams for the Remote Repositories if the resource is in + the perimeter. + ALLOW (2): + VPCSC_ALLOW - repository will allow the requests to the + Upstreams for the Remote Repositories if the resource is in + the perimeter. + """ + VPCSC_POLICY_UNSPECIFIED = 0 + DENY = 1 + ALLOW = 2 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + vpcsc_policy: VPCSCPolicy = proto.Field( + proto.ENUM, + number=2, + enum=VPCSCPolicy, + ) + + +class GetVPCSCConfigRequest(proto.Message): + r"""Gets the VPC SC config for a project. + + Attributes: + name (str): + Required. The name of the VPCSCConfig + resource. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateVPCSCConfigRequest(proto.Message): + r"""Sets the VPCSC config of the project. + + Attributes: + vpcsc_config (google.cloud.artifactregistry_v1.types.VPCSCConfig): + The project config. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Field mask to support partial updates. + """ + + vpcsc_config: "VPCSCConfig" = proto.Field( + proto.MESSAGE, + number=1, + message="VPCSCConfig", + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/artifactregistry_v1beta2/__init__.py b/google/cloud/artifactregistry_v1beta2/__init__.py index d43f036..970c964 100644 --- a/google/cloud/artifactregistry_v1beta2/__init__.py +++ b/google/cloud/artifactregistry_v1beta2/__init__.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from google.cloud.artifactregistry import gapic_version as package_version +from google.cloud.artifactregistry_v1beta2 import gapic_version as package_version __version__ = package_version.__version__ diff --git a/google/cloud/artifactregistry_v1beta2/gapic_version.py b/google/cloud/artifactregistry_v1beta2/gapic_version.py index b4028ab..f033c61 100644 --- a/google/cloud/artifactregistry_v1beta2/gapic_version.py +++ b/google/cloud/artifactregistry_v1beta2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.1" # {x-release-please-version} +__version__ = "1.7.0" # {x-release-please-version} diff --git a/noxfile.py b/noxfile.py index e716318..95e58c5 100644 --- a/noxfile.py +++ b/noxfile.py @@ -189,9 +189,9 @@ def unit(session): def install_systemtest_dependencies(session, *constraints): # Use pre-release gRPC for system tests. - # Exclude version 1.49.0rc1 which has a known issue. - # See https://github.com/grpc/grpc/pull/30642 - session.install("--pre", "grpcio!=1.49.0rc1") + # Exclude version 1.52.0rc1 which has a known issue. + # See https://github.com/grpc/grpc/issues/32163 + session.install("--pre", "grpcio!=1.52.0rc1") session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) @@ -346,9 +346,7 @@ def prerelease_deps(session): unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES session.install(*unit_deps_all) system_deps_all = ( - SYSTEM_TEST_STANDARD_DEPENDENCIES - + SYSTEM_TEST_EXTERNAL_DEPENDENCIES - + SYSTEM_TEST_EXTRAS + SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES ) session.install(*system_deps_all) @@ -378,8 +376,8 @@ def prerelease_deps(session): # dependency of grpc "six", "googleapis-common-protos", - # Exclude version 1.49.0rc1 which has a known issue. See https://github.com/grpc/grpc/pull/30642 - "grpcio!=1.49.0rc1", + # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163 + "grpcio!=1.52.0rc1", "grpcio-status", "google-api-core", "proto-plus", diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_async.py index 8d29f4e..e5fdf8f 100644 --- a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_async.py +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_async.py @@ -40,6 +40,7 @@ async def sample_get_file(): # Initialize request argument(s) request = artifactregistry_v1.GetFileRequest( + name="name_value", ) # Make the request diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_sync.py index 064855b..f89111b 100644 --- a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_sync.py +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_sync.py @@ -40,6 +40,7 @@ def sample_get_file(): # Initialize request argument(s) request = artifactregistry_v1.GetFileRequest( + name="name_value", ) # Make the request diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py new file mode 100644 index 0000000..ddbbc01 --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetMavenArtifact +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +async def sample_get_maven_artifact(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetMavenArtifactRequest( + name="name_value", + ) + + # Make the request + response = await client.get_maven_artifact(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_async] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py new file mode 100644 index 0000000..34ef8ae --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetMavenArtifact +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +def sample_get_maven_artifact(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetMavenArtifactRequest( + name="name_value", + ) + + # Make the request + response = client.get_maven_artifact(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_sync] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py new file mode 100644 index 0000000..a94e8a0 --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetNpmPackage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +async def sample_get_npm_package(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetNpmPackageRequest( + name="name_value", + ) + + # Make the request + response = await client.get_npm_package(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_async] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py new file mode 100644 index 0000000..923c676 --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetNpmPackage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +def sample_get_npm_package(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetNpmPackageRequest( + name="name_value", + ) + + # Make the request + response = client.get_npm_package(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_sync] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_async.py new file mode 100644 index 0000000..1b6d75d --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPythonPackage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +async def sample_get_python_package(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetPythonPackageRequest( + name="name_value", + ) + + # Make the request + response = await client.get_python_package(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_async] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py new file mode 100644 index 0000000..690f4ee --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPythonPackage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +def sample_get_python_package(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetPythonPackageRequest( + name="name_value", + ) + + # Make the request + response = client.get_python_package(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_sync] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py new file mode 100644 index 0000000..1d6b8a5 --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVPCSCConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_GetVPCSCConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +async def sample_get_vpcsc_config(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetVPCSCConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vpcsc_config(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_GetVPCSCConfig_async] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py new file mode 100644 index 0000000..bc03ea7 --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVPCSCConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_GetVPCSCConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +def sample_get_vpcsc_config(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetVPCSCConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_vpcsc_config(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_GetVPCSCConfig_sync] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_async.py index 27a4f6c..8a099a6 100644 --- a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_async.py +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_async.py @@ -40,6 +40,7 @@ async def sample_list_files(): # Initialize request argument(s) request = artifactregistry_v1.ListFilesRequest( + parent="parent_value", ) # Make the request diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_sync.py index cb4fb3a..97f399c 100644 --- a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_sync.py +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_sync.py @@ -40,6 +40,7 @@ def sample_list_files(): # Initialize request argument(s) request = artifactregistry_v1.ListFilesRequest( + parent="parent_value", ) # Make the request diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py new file mode 100644 index 0000000..00a824d --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListMavenArtifacts +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_ListMavenArtifacts_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +async def sample_list_maven_artifacts(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListMavenArtifactsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_maven_artifacts(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_ListMavenArtifacts_async] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py new file mode 100644 index 0000000..d934cce --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListMavenArtifacts +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_ListMavenArtifacts_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +def sample_list_maven_artifacts(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListMavenArtifactsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_maven_artifacts(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_ListMavenArtifacts_sync] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py new file mode 100644 index 0000000..f360c47 --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListNpmPackages +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_ListNpmPackages_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +async def sample_list_npm_packages(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListNpmPackagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_npm_packages(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_ListNpmPackages_async] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py new file mode 100644 index 0000000..01d7a2a --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListNpmPackages +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_ListNpmPackages_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +def sample_list_npm_packages(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListNpmPackagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_npm_packages(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_ListNpmPackages_sync] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py new file mode 100644 index 0000000..34cc1fe --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPythonPackages +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_ListPythonPackages_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +async def sample_list_python_packages(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListPythonPackagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_python_packages(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_ListPythonPackages_async] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py new file mode 100644 index 0000000..7aa08b1 --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPythonPackages +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_ListPythonPackages_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +def sample_list_python_packages(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListPythonPackagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_python_packages(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_ListPythonPackages_sync] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py new file mode 100644 index 0000000..e30682e --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateVPCSCConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +async def sample_update_vpcsc_config(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateVPCSCConfigRequest( + ) + + # Make the request + response = await client.update_vpcsc_config(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_async] diff --git a/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py new file mode 100644 index 0000000..a7267b0 --- /dev/null +++ b/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateVPCSCConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-artifact-registry + + +# [START artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import artifactregistry_v1 + + +def sample_update_vpcsc_config(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateVPCSCConfigRequest( + ) + + # Make the request + response = client.update_vpcsc_config(request=request) + + # Handle the response + print(response) + +# [END artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_sync] diff --git a/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json b/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json index 19cecd3..f0d487d 100644 --- a/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json +++ b/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-artifact-registry", - "version": "1.6.1" + "version": "1.7.0" }, "snippets": [ { @@ -1213,12 +1213,12 @@ "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetFile_async", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -1228,18 +1228,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -1293,12 +1293,12 @@ "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetFile_sync", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -1308,18 +1308,18 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], @@ -1486,19 +1486,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_maven_artifact", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetMavenArtifact", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetPackage" + "shortName": "GetMavenArtifact" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" + "type": "google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest" }, { "name": "name", @@ -1517,14 +1517,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Package", - "shortName": "get_package" + "resultType": "google.cloud.artifactregistry_v1.types.MavenArtifact", + "shortName": "get_maven_artifact" }, - "description": "Sample for GetPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_package_async.py", + "description": "Sample for GetMavenArtifact", + "file": "artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_async", "segments": [ { "end": 51, @@ -1557,7 +1557,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_package_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py" }, { "canonical": true, @@ -1566,19 +1566,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_maven_artifact", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetMavenArtifact", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetPackage" + "shortName": "GetMavenArtifact" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" + "type": "google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest" }, { "name": "name", @@ -1597,14 +1597,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Package", - "shortName": "get_package" + "resultType": "google.cloud.artifactregistry_v1.types.MavenArtifact", + "shortName": "get_maven_artifact" }, - "description": "Sample for GetPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_package_sync.py", + "description": "Sample for GetMavenArtifact", + "file": "artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_sync", "segments": [ { "end": 51, @@ -1637,7 +1637,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_package_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py" }, { "canonical": true, @@ -1647,19 +1647,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_project_settings", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_npm_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetNpmPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetProjectSettings" + "shortName": "GetNpmPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetNpmPackageRequest" }, { "name": "name", @@ -1678,14 +1678,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", - "shortName": "get_project_settings" + "resultType": "google.cloud.artifactregistry_v1.types.NpmPackage", + "shortName": "get_npm_package" }, - "description": "Sample for GetProjectSettings", - "file": "artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py", + "description": "Sample for GetNpmPackage", + "file": "artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_async", "segments": [ { "end": 51, @@ -1718,7 +1718,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py" }, { "canonical": true, @@ -1727,19 +1727,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_project_settings", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_npm_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetNpmPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetProjectSettings" + "shortName": "GetNpmPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetNpmPackageRequest" }, { "name": "name", @@ -1758,14 +1758,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", - "shortName": "get_project_settings" + "resultType": "google.cloud.artifactregistry_v1.types.NpmPackage", + "shortName": "get_npm_package" }, - "description": "Sample for GetProjectSettings", - "file": "artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py", + "description": "Sample for GetNpmPackage", + "file": "artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_sync", "segments": [ { "end": 51, @@ -1798,7 +1798,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py" }, { "canonical": true, @@ -1808,19 +1808,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetRepository" + "shortName": "GetPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" + "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" }, { "name": "name", @@ -1839,14 +1839,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Repository", - "shortName": "get_repository" + "resultType": "google.cloud.artifactregistry_v1.types.Package", + "shortName": "get_package" }, - "description": "Sample for GetRepository", - "file": "artifactregistry_v1_generated_artifact_registry_get_repository_async.py", + "description": "Sample for GetPackage", + "file": "artifactregistry_v1_generated_artifact_registry_get_package_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_async", "segments": [ { "end": 51, @@ -1879,7 +1879,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_repository_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_package_async.py" }, { "canonical": true, @@ -1888,19 +1888,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetRepository" + "shortName": "GetPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" + "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" }, { "name": "name", @@ -1919,14 +1919,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Repository", - "shortName": "get_repository" + "resultType": "google.cloud.artifactregistry_v1.types.Package", + "shortName": "get_package" }, - "description": "Sample for GetRepository", - "file": "artifactregistry_v1_generated_artifact_registry_get_repository_sync.py", + "description": "Sample for GetPackage", + "file": "artifactregistry_v1_generated_artifact_registry_get_package_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_sync", "segments": [ { "end": 51, @@ -1959,7 +1959,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_repository_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_package_sync.py" }, { "canonical": true, @@ -1969,19 +1969,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_project_settings", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetTag" + "shortName": "GetProjectSettings" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" + "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" }, { "name": "name", @@ -2000,22 +2000,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "get_tag" + "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", + "shortName": "get_project_settings" }, - "description": "Sample for GetTag", - "file": "artifactregistry_v1_generated_artifact_registry_get_tag_async.py", + "description": "Sample for GetProjectSettings", + "file": "artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetTag_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_async", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2025,22 +2025,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_tag_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py" }, { "canonical": true, @@ -2049,19 +2049,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_project_settings", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetTag" + "shortName": "GetProjectSettings" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" + "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" }, { "name": "name", @@ -2080,22 +2080,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "get_tag" + "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", + "shortName": "get_project_settings" }, - "description": "Sample for GetTag", - "file": "artifactregistry_v1_generated_artifact_registry_get_tag_sync.py", + "description": "Sample for GetProjectSettings", + "file": "artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetTag_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_sync", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2105,22 +2105,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_tag_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py" }, { "canonical": true, @@ -2130,19 +2130,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_version", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_python_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVersion", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPythonPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetVersion" + "shortName": "GetPythonPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetVersionRequest" + "type": "google.cloud.artifactregistry_v1.types.GetPythonPackageRequest" }, { "name": "name", @@ -2161,22 +2161,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Version", - "shortName": "get_version" + "resultType": "google.cloud.artifactregistry_v1.types.PythonPackage", + "shortName": "get_python_package" }, - "description": "Sample for GetVersion", - "file": "artifactregistry_v1_generated_artifact_registry_get_version_async.py", + "description": "Sample for GetPythonPackage", + "file": "artifactregistry_v1_generated_artifact_registry_get_python_package_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVersion_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_async", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2186,22 +2186,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_version_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_python_package_async.py" }, { "canonical": true, @@ -2210,19 +2210,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_version", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_python_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVersion", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPythonPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetVersion" + "shortName": "GetPythonPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetVersionRequest" + "type": "google.cloud.artifactregistry_v1.types.GetPythonPackageRequest" }, { "name": "name", @@ -2241,22 +2241,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Version", - "shortName": "get_version" + "resultType": "google.cloud.artifactregistry_v1.types.PythonPackage", + "shortName": "get_python_package" }, - "description": "Sample for GetVersion", - "file": "artifactregistry_v1_generated_artifact_registry_get_version_sync.py", + "description": "Sample for GetPythonPackage", + "file": "artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVersion_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_sync", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2266,22 +2266,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_version_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py" }, { "canonical": true, @@ -2291,19 +2291,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.import_apt_artifacts", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportAptArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ImportAptArtifacts" + "shortName": "GetRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -2318,22 +2322,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "import_apt_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.Repository", + "shortName": "get_repository" }, - "description": "Sample for ImportAptArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py", + "description": "Sample for GetRepository", + "file": "artifactregistry_v1_generated_artifact_registry_get_repository_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportAptArtifacts_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_async", "segments": [ { - "end": 54, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2343,22 +2347,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 51, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_repository_async.py" }, { "canonical": true, @@ -2367,19 +2371,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.import_apt_artifacts", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportAptArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ImportAptArtifacts" + "shortName": "GetRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -2394,22 +2402,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "import_apt_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.Repository", + "shortName": "get_repository" }, - "description": "Sample for ImportAptArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py", + "description": "Sample for GetRepository", + "file": "artifactregistry_v1_generated_artifact_registry_get_repository_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportAptArtifacts_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_sync", "segments": [ { - "end": 54, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2419,22 +2427,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 51, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_repository_sync.py" }, { "canonical": true, @@ -2444,19 +2452,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.import_yum_artifacts", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportYumArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ImportYumArtifacts" + "shortName": "GetTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -2471,22 +2483,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "import_yum_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.Tag", + "shortName": "get_tag" }, - "description": "Sample for ImportYumArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py", + "description": "Sample for GetTag", + "file": "artifactregistry_v1_generated_artifact_registry_get_tag_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportYumArtifacts_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetTag_async", "segments": [ { - "end": 54, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 50, "start": 27, "type": "SHORT" }, @@ -2501,17 +2513,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 51, + "end": 47, "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_tag_async.py" }, { "canonical": true, @@ -2520,19 +2532,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.import_yum_artifacts", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportYumArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ImportYumArtifacts" + "shortName": "GetTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -2547,22 +2563,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "import_yum_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.Tag", + "shortName": "get_tag" }, - "description": "Sample for ImportYumArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py", + "description": "Sample for GetTag", + "file": "artifactregistry_v1_generated_artifact_registry_get_tag_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportYumArtifacts_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetTag_sync", "segments": [ { - "end": 54, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 50, "start": 27, "type": "SHORT" }, @@ -2577,17 +2593,1128 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 51, + "end": 47, "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_get_tag_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_vpcsc_config", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVPCSCConfig", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "GetVPCSCConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.GetVPCSCConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", + "shortName": "get_vpcsc_config" + }, + "description": "Sample for GetVPCSCConfig", + "file": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVPCSCConfig_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_vpcsc_config", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVPCSCConfig", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "GetVPCSCConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.GetVPCSCConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", + "shortName": "get_vpcsc_config" + }, + "description": "Sample for GetVPCSCConfig", + "file": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVPCSCConfig_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_version", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVersion", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "GetVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.GetVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.types.Version", + "shortName": "get_version" + }, + "description": "Sample for GetVersion", + "file": "artifactregistry_v1_generated_artifact_registry_get_version_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVersion_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_get_version_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_version", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVersion", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "GetVersion" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.GetVersionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.types.Version", + "shortName": "get_version" + }, + "description": "Sample for GetVersion", + "file": "artifactregistry_v1_generated_artifact_registry_get_version_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVersion_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_get_version_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.import_apt_artifacts", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportAptArtifacts", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ImportAptArtifacts" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "import_apt_artifacts" + }, + "description": "Sample for ImportAptArtifacts", + "file": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportAptArtifacts_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.import_apt_artifacts", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportAptArtifacts", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ImportAptArtifacts" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "import_apt_artifacts" + }, + "description": "Sample for ImportAptArtifacts", + "file": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportAptArtifacts_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.import_yum_artifacts", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportYumArtifacts", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ImportYumArtifacts" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "import_yum_artifacts" + }, + "description": "Sample for ImportYumArtifacts", + "file": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportYumArtifacts_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.import_yum_artifacts", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportYumArtifacts", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ImportYumArtifacts" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "import_yum_artifacts" + }, + "description": "Sample for ImportYumArtifacts", + "file": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportYumArtifacts_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_docker_images", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListDockerImages", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListDockerImages" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListDockerImagesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesAsyncPager", + "shortName": "list_docker_images" + }, + "description": "Sample for ListDockerImages", + "file": "artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListDockerImages_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_docker_images", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListDockerImages", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListDockerImages" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListDockerImagesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesPager", + "shortName": "list_docker_images" + }, + "description": "Sample for ListDockerImages", + "file": "artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListDockerImages_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_files", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListFiles", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListFiles" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListFilesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesAsyncPager", + "shortName": "list_files" + }, + "description": "Sample for ListFiles", + "file": "artifactregistry_v1_generated_artifact_registry_list_files_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListFiles_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_files_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_files", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListFiles", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListFiles" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListFilesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesPager", + "shortName": "list_files" + }, + "description": "Sample for ListFiles", + "file": "artifactregistry_v1_generated_artifact_registry_list_files_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListFiles_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_files_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_maven_artifacts", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListMavenArtifacts", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListMavenArtifacts" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListMavenArtifactsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsAsyncPager", + "shortName": "list_maven_artifacts" + }, + "description": "Sample for ListMavenArtifacts", + "file": "artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListMavenArtifacts_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_maven_artifacts", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListMavenArtifacts", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListMavenArtifacts" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListMavenArtifactsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsPager", + "shortName": "list_maven_artifacts" + }, + "description": "Sample for ListMavenArtifacts", + "file": "artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListMavenArtifacts_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py" }, { "canonical": true, @@ -2597,19 +3724,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_docker_images", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_npm_packages", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListDockerImages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListNpmPackages", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListDockerImages" + "shortName": "ListNpmPackages" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListDockerImagesRequest" + "type": "google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest" }, { "name": "parent", @@ -2628,14 +3755,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesAsyncPager", - "shortName": "list_docker_images" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesAsyncPager", + "shortName": "list_npm_packages" }, - "description": "Sample for ListDockerImages", - "file": "artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py", + "description": "Sample for ListNpmPackages", + "file": "artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListDockerImages_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListNpmPackages_async", "segments": [ { "end": 52, @@ -2668,7 +3795,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py" }, { "canonical": true, @@ -2677,19 +3804,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_docker_images", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_npm_packages", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListDockerImages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListNpmPackages", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListDockerImages" + "shortName": "ListNpmPackages" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListDockerImagesRequest" + "type": "google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest" }, { "name": "parent", @@ -2708,14 +3835,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesPager", - "shortName": "list_docker_images" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesPager", + "shortName": "list_npm_packages" }, - "description": "Sample for ListDockerImages", - "file": "artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py", + "description": "Sample for ListNpmPackages", + "file": "artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListDockerImages_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListNpmPackages_sync", "segments": [ { "end": 52, @@ -2748,7 +3875,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py" }, { "canonical": true, @@ -2758,19 +3885,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_files", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_packages", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListFiles", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListFiles" + "shortName": "ListPackages" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListFilesRequest" + "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" }, { "name": "parent", @@ -2789,22 +3916,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesAsyncPager", - "shortName": "list_files" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesAsyncPager", + "shortName": "list_packages" }, - "description": "Sample for ListFiles", - "file": "artifactregistry_v1_generated_artifact_registry_list_files_async.py", + "description": "Sample for ListPackages", + "file": "artifactregistry_v1_generated_artifact_registry_list_packages_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListFiles_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -2814,22 +3941,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 48, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_files_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_packages_async.py" }, { "canonical": true, @@ -2838,19 +3965,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_files", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_packages", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListFiles", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListFiles" + "shortName": "ListPackages" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListFilesRequest" + "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" }, { "name": "parent", @@ -2869,22 +3996,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesPager", - "shortName": "list_files" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesPager", + "shortName": "list_packages" }, - "description": "Sample for ListFiles", - "file": "artifactregistry_v1_generated_artifact_registry_list_files_sync.py", + "description": "Sample for ListPackages", + "file": "artifactregistry_v1_generated_artifact_registry_list_packages_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListFiles_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -2894,22 +4021,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 48, + "end": 53, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_files_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_packages_sync.py" }, { "canonical": true, @@ -2919,19 +4046,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_packages", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_python_packages", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPythonPackages", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListPackages" + "shortName": "ListPythonPackages" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" + "type": "google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest" }, { "name": "parent", @@ -2950,14 +4077,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesAsyncPager", - "shortName": "list_packages" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesAsyncPager", + "shortName": "list_python_packages" }, - "description": "Sample for ListPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_packages_async.py", + "description": "Sample for ListPythonPackages", + "file": "artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPythonPackages_async", "segments": [ { "end": 52, @@ -2990,7 +4117,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_packages_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py" }, { "canonical": true, @@ -2999,19 +4126,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_packages", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_python_packages", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPythonPackages", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListPackages" + "shortName": "ListPythonPackages" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" + "type": "google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest" }, { "name": "parent", @@ -3030,14 +4157,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesPager", - "shortName": "list_packages" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesPager", + "shortName": "list_python_packages" }, - "description": "Sample for ListPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_packages_sync.py", + "description": "Sample for ListPythonPackages", + "file": "artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPythonPackages_sync", "segments": [ { "end": 52, @@ -3070,7 +4197,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_packages_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py" }, { "canonical": true, @@ -4367,6 +5494,175 @@ } ], "title": "artifactregistry_v1_generated_artifact_registry_update_tag_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_vpcsc_config", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVPCSCConfig", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "UpdateVPCSCConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.UpdateVPCSCConfigRequest" + }, + { + "name": "vpcsc_config", + "type": "google.cloud.artifactregistry_v1.types.VPCSCConfig" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", + "shortName": "update_vpcsc_config" + }, + "description": "Sample for UpdateVPCSCConfig", + "file": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_vpcsc_config", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVPCSCConfig", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "UpdateVPCSCConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.UpdateVPCSCConfigRequest" + }, + { + "name": "vpcsc_config", + "type": "google.cloud.artifactregistry_v1.types.VPCSCConfig" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", + "shortName": "update_vpcsc_config" + }, + "description": "Sample for UpdateVPCSCConfig", + "file": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json b/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json index 5c37dff..0a38829 100644 --- a/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json +++ b/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-artifact-registry", - "version": "1.6.1" + "version": "1.7.0" }, "snippets": [ { diff --git a/scripts/fixup_artifactregistry_v1_keywords.py b/scripts/fixup_artifactregistry_v1_keywords.py index a6403ff..2038609 100644 --- a/scripts/fixup_artifactregistry_v1_keywords.py +++ b/scripts/fixup_artifactregistry_v1_keywords.py @@ -48,16 +48,23 @@ class artifactregistryCallTransformer(cst.CSTTransformer): 'get_docker_image': ('name', ), 'get_file': ('name', ), 'get_iam_policy': ('resource', 'options', ), + 'get_maven_artifact': ('name', ), + 'get_npm_package': ('name', ), 'get_package': ('name', ), 'get_project_settings': ('name', ), + 'get_python_package': ('name', ), 'get_repository': ('name', ), 'get_tag': ('name', ), 'get_version': ('name', 'view', ), + 'get_vpcsc_config': ('name', ), 'import_apt_artifacts': ('gcs_source', 'parent', ), 'import_yum_artifacts': ('gcs_source', 'parent', ), - 'list_docker_images': ('parent', 'page_size', 'page_token', ), + 'list_docker_images': ('parent', 'page_size', 'page_token', 'order_by', ), 'list_files': ('parent', 'filter', 'page_size', 'page_token', 'order_by', ), + 'list_maven_artifacts': ('parent', 'page_size', 'page_token', ), + 'list_npm_packages': ('parent', 'page_size', 'page_token', ), 'list_packages': ('parent', 'page_size', 'page_token', ), + 'list_python_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', 'order_by', ), @@ -66,6 +73,7 @@ class artifactregistryCallTransformer(cst.CSTTransformer): 'update_project_settings': ('project_settings', 'update_mask', ), 'update_repository': ('repository', 'update_mask', ), 'update_tag': ('tag', 'update_mask', ), + 'update_vpcsc_config': ('vpcsc_config', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py b/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py index 3759e1a..b5ac7fd 100644 --- a/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py +++ b/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py @@ -63,12 +63,15 @@ transports, ) from google.cloud.artifactregistry_v1.types import apt_artifact, artifact, file, package +from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config from google.cloud.artifactregistry_v1.types import repository from google.cloud.artifactregistry_v1.types import repository as gda_repository from google.cloud.artifactregistry_v1.types import service, settings from google.cloud.artifactregistry_v1.types import tag from google.cloud.artifactregistry_v1.types import tag as gda_tag -from google.cloud.artifactregistry_v1.types import version, yum_artifact +from google.cloud.artifactregistry_v1.types import version +from google.cloud.artifactregistry_v1.types import vpcsc_config +from google.cloud.artifactregistry_v1.types import yum_artifact def client_cert_source_callback(): @@ -1416,11 +1419,11 @@ async def test_get_docker_image_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - apt_artifact.ImportAptArtifactsRequest, + artifact.ListMavenArtifactsRequest, dict, ], ) -def test_import_apt_artifacts(request_type, transport: str = "grpc"): +def test_list_maven_artifacts(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -1432,22 +1435,25 @@ def test_import_apt_artifacts(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_apt_artifacts), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.import_apt_artifacts(request) + call.return_value = artifact.ListMavenArtifactsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_maven_artifacts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apt_artifact.ImportAptArtifactsRequest() + assert args[0] == artifact.ListMavenArtifactsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, pagers.ListMavenArtifactsPager) + assert response.next_page_token == "next_page_token_value" -def test_import_apt_artifacts_empty_call(): +def test_list_maven_artifacts_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( @@ -1457,17 +1463,17 @@ def test_import_apt_artifacts_empty_call(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_apt_artifacts), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: - client.import_apt_artifacts() + client.list_maven_artifacts() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apt_artifact.ImportAptArtifactsRequest() + assert args[0] == artifact.ListMavenArtifactsRequest() @pytest.mark.asyncio -async def test_import_apt_artifacts_async( - transport: str = "grpc_asyncio", request_type=apt_artifact.ImportAptArtifactsRequest +async def test_list_maven_artifacts_async( + transport: str = "grpc_asyncio", request_type=artifact.ListMavenArtifactsRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -1480,45 +1486,48 @@ async def test_import_apt_artifacts_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_apt_artifacts), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + artifact.ListMavenArtifactsResponse( + next_page_token="next_page_token_value", + ) ) - response = await client.import_apt_artifacts(request) + response = await client.list_maven_artifacts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apt_artifact.ImportAptArtifactsRequest() + assert args[0] == artifact.ListMavenArtifactsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, pagers.ListMavenArtifactsAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_import_apt_artifacts_async_from_dict(): - await test_import_apt_artifacts_async(request_type=dict) +async def test_list_maven_artifacts_async_from_dict(): + await test_list_maven_artifacts_async(request_type=dict) -def test_import_apt_artifacts_field_headers(): +def test_list_maven_artifacts_field_headers(): 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 = apt_artifact.ImportAptArtifactsRequest() + request = artifact.ListMavenArtifactsRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_apt_artifacts), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.import_apt_artifacts(request) + call.return_value = artifact.ListMavenArtifactsResponse() + client.list_maven_artifacts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -1534,25 +1543,25 @@ def test_import_apt_artifacts_field_headers(): @pytest.mark.asyncio -async def test_import_apt_artifacts_field_headers_async(): +async def test_list_maven_artifacts_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = apt_artifact.ImportAptArtifactsRequest() + request = artifact.ListMavenArtifactsRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_apt_artifacts), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") + artifact.ListMavenArtifactsResponse() ) - await client.import_apt_artifacts(request) + await client.list_maven_artifacts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -1567,218 +1576,354 @@ async def test_import_apt_artifacts_field_headers_async(): ) in kw["metadata"] -@pytest.mark.parametrize( - "request_type", - [ - yum_artifact.ImportYumArtifactsRequest, - dict, - ], -) -def test_import_yum_artifacts(request_type, transport: str = "grpc"): +def test_list_maven_artifacts_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_yum_artifacts), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.import_yum_artifacts(request) + call.return_value = artifact.ListMavenArtifactsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_maven_artifacts( + parent="parent_value", + ) - # Establish that the underlying gRPC stub method was called. + # 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] == yum_artifact.ImportYumArtifactsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_import_yum_artifacts_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. +def test_list_maven_artifacts_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.import_yum_artifacts), "__call__" - ) as call: - client.import_yum_artifacts() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == yum_artifact.ImportYumArtifactsRequest() + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_maven_artifacts( + artifact.ListMavenArtifactsRequest(), + parent="parent_value", + ) @pytest.mark.asyncio -async def test_import_yum_artifacts_async( - transport: str = "grpc_asyncio", request_type=yum_artifact.ImportYumArtifactsRequest -): +async def test_list_maven_artifacts_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_yum_artifacts), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: # Designate an appropriate return value for the call. + call.return_value = artifact.ListMavenArtifactsResponse() + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + artifact.ListMavenArtifactsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_maven_artifacts( + parent="parent_value", ) - response = await client.import_yum_artifacts(request) - # Establish that the underlying gRPC stub method was called. + # 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] == yum_artifact.ImportYumArtifactsRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio -async def test_import_yum_artifacts_async_from_dict(): - await test_import_yum_artifacts_async(request_type=dict) - - -def test_import_yum_artifacts_field_headers(): - client = ArtifactRegistryClient( +async def test_list_maven_artifacts_flattened_error_async(): + client = ArtifactRegistryAsyncClient( 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 = yum_artifact.ImportYumArtifactsRequest() - - request.parent = "parent_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.import_yum_artifacts), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_maven_artifacts( + artifact.ListMavenArtifactsRequest(), + parent="parent_value", + ) -@pytest.mark.asyncio -async def test_import_yum_artifacts_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), +def test_list_maven_artifacts_pager(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) - # 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 = yum_artifact.ImportYumArtifactsRequest() - - request.parent = "parent_value" - # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.import_yum_artifacts), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + artifact.MavenArtifact(), + ], + next_page_token="abc", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[], + next_page_token="def", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + ], + next_page_token="ghi", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + ], + ), + RuntimeError, ) - await client.import_yum_artifacts(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_maven_artifacts(request={}) - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "parent=parent_value", - ) in kw["metadata"] + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, artifact.MavenArtifact) for i in results) -@pytest.mark.parametrize( - "request_type", - [ - repository.ListRepositoriesRequest, - dict, - ], -) -def test_list_repositories(request_type, transport: str = "grpc"): +def test_list_maven_artifacts_pages(transport_name: str = "grpc"): client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.list_maven_artifacts), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = repository.ListRepositoriesResponse( - next_page_token="next_page_token_value", + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + artifact.MavenArtifact(), + ], + next_page_token="abc", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[], + next_page_token="def", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + ], + next_page_token="ghi", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + ], + ), + RuntimeError, ) - 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" + pages = list(client.list_maven_artifacts(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -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=ga_credentials.AnonymousCredentials(), - transport="grpc", +@pytest.mark.asyncio +async def test_list_maven_artifacts_async_pager(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.list_maven_artifacts), + "__call__", + new_callable=mock.AsyncMock, ) as call: - client.list_repositories() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == repository.ListRepositoriesRequest() - - + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + artifact.MavenArtifact(), + ], + next_page_token="abc", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[], + next_page_token="def", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + ], + next_page_token="ghi", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_maven_artifacts( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, artifact.MavenArtifact) for i in responses) + + @pytest.mark.asyncio -async def test_list_repositories_async( - transport: str = "grpc_asyncio", request_type=repository.ListRepositoriesRequest +async def test_list_maven_artifacts_async_pages(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_maven_artifacts), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + artifact.MavenArtifact(), + ], + next_page_token="abc", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[], + next_page_token="def", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + ], + next_page_token="ghi", + ), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_maven_artifacts(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.GetMavenArtifactRequest, + dict, + ], +) +def test_get_maven_artifact(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_maven_artifact), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = artifact.MavenArtifact( + name="name_value", + pom_uri="pom_uri_value", + group_id="group_id_value", + artifact_id="artifact_id_value", + version="version_value", + ) + response = client.get_maven_artifact(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == artifact.GetMavenArtifactRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, artifact.MavenArtifact) + assert response.name == "name_value" + assert response.pom_uri == "pom_uri_value" + assert response.group_id == "group_id_value" + assert response.artifact_id == "artifact_id_value" + assert response.version == "version_value" + + +def test_get_maven_artifact_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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_maven_artifact), "__call__" + ) as call: + client.get_maven_artifact() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == artifact.GetMavenArtifactRequest() + + +@pytest.mark.asyncio +async def test_get_maven_artifact_async( + transport: str = "grpc_asyncio", request_type=artifact.GetMavenArtifactRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -1791,48 +1936,56 @@ async def test_list_repositories_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.get_maven_artifact), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - repository.ListRepositoriesResponse( - next_page_token="next_page_token_value", + artifact.MavenArtifact( + name="name_value", + pom_uri="pom_uri_value", + group_id="group_id_value", + artifact_id="artifact_id_value", + version="version_value", ) ) - response = await client.list_repositories(request) + response = await client.get_maven_artifact(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() + assert args[0] == artifact.GetMavenArtifactRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRepositoriesAsyncPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, artifact.MavenArtifact) + assert response.name == "name_value" + assert response.pom_uri == "pom_uri_value" + assert response.group_id == "group_id_value" + assert response.artifact_id == "artifact_id_value" + assert response.version == "version_value" @pytest.mark.asyncio -async def test_list_repositories_async_from_dict(): - await test_list_repositories_async(request_type=dict) +async def test_get_maven_artifact_async_from_dict(): + await test_get_maven_artifact_async(request_type=dict) -def test_list_repositories_field_headers(): +def test_get_maven_artifact_field_headers(): 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 = artifact.GetMavenArtifactRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.get_maven_artifact), "__call__" ) as call: - call.return_value = repository.ListRepositoriesResponse() - client.list_repositories(request) + call.return_value = artifact.MavenArtifact() + client.get_maven_artifact(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -1843,30 +1996,30 @@ def test_list_repositories_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_list_repositories_field_headers_async(): +async def test_get_maven_artifact_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = artifact.GetMavenArtifactRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.get_maven_artifact), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - repository.ListRepositoriesResponse() + artifact.MavenArtifact() ) - await client.list_repositories(request) + await client.get_maven_artifact(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -1877,37 +2030,37 @@ async def test_list_repositories_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] -def test_list_repositories_flattened(): +def test_get_maven_artifact_flattened(): 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_repositories), "__call__" + type(client.transport.get_maven_artifact), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = repository.ListRepositoriesResponse() + call.return_value = artifact.MavenArtifact() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_repositories( - parent="parent_value", + client.get_maven_artifact( + name="name_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] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_list_repositories_flattened_error(): +def test_get_maven_artifact_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -1915,45 +2068,45 @@ def test_list_repositories_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_repositories( - repository.ListRepositoriesRequest(), - parent="parent_value", + client.get_maven_artifact( + artifact.GetMavenArtifactRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_list_repositories_flattened_async(): +async def test_get_maven_artifact_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.get_maven_artifact), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = repository.ListRepositoriesResponse() + call.return_value = artifact.MavenArtifact() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - repository.ListRepositoriesResponse() + artifact.MavenArtifact() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_repositories( - parent="parent_value", + response = await client.get_maven_artifact( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_list_repositories_flattened_error_async(): +async def test_get_maven_artifact_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -1961,271 +2114,70 @@ async def test_list_repositories_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_repositories( - repository.ListRepositoriesRequest(), - parent="parent_value", + await client.get_maven_artifact( + artifact.GetMavenArtifactRequest(), + name="name_value", ) -def test_list_repositories_pager(transport_name: str = "grpc"): +@pytest.mark.parametrize( + "request_type", + [ + artifact.ListNpmPackagesRequest, + dict, + ], +) +def test_list_npm_packages(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.list_npm_packages), "__call__" ) as call: - # Set the response to a series of pages. - call.side_effect = ( - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - repository.Repository(), - repository.Repository(), - ], - next_page_token="abc", - ), - repository.ListRepositoriesResponse( - repositories=[], - next_page_token="def", - ), - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - ], - next_page_token="ghi", - ), - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - repository.Repository(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + # Designate an appropriate return value for the call. + call.return_value = artifact.ListNpmPackagesResponse( + next_page_token="next_page_token_value", ) - pager = client.list_repositories(request={}) + response = client.list_npm_packages(request) - assert pager._metadata == metadata + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == artifact.ListNpmPackagesRequest() - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, repository.Repository) for i in results) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListNpmPackagesPager) + assert response.next_page_token == "next_page_token_value" -def test_list_repositories_pages(transport_name: str = "grpc"): +def test_list_npm_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=ga_credentials.AnonymousCredentials, - transport=transport_name, + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.list_npm_packages), "__call__" ) as call: - # Set the response to a series of pages. - call.side_effect = ( - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - repository.Repository(), - repository.Repository(), - ], - next_page_token="abc", - ), - repository.ListRepositoriesResponse( - repositories=[], - next_page_token="def", - ), - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - ], - next_page_token="ghi", - ), - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - repository.Repository(), - ], - ), - RuntimeError, - ) - pages = list(client.list_repositories(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_list_repositories_async_pager(): - client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_repositories), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - repository.Repository(), - repository.Repository(), - ], - next_page_token="abc", - ), - repository.ListRepositoriesResponse( - repositories=[], - next_page_token="def", - ), - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - ], - next_page_token="ghi", - ), - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - repository.Repository(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_repositories( - request={}, - ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, repository.Repository) for i in responses) - - -@pytest.mark.asyncio -async def test_list_repositories_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_repositories), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - repository.Repository(), - repository.Repository(), - ], - next_page_token="abc", - ), - repository.ListRepositoriesResponse( - repositories=[], - next_page_token="def", - ), - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - ], - next_page_token="ghi", - ), - repository.ListRepositoriesResponse( - repositories=[ - repository.Repository(), - repository.Repository(), - ], - ), - RuntimeError, - ) - pages = [] - async for page_ in ( - await client.list_repositories(request={}) - ).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize( - "request_type", - [ - repository.GetRepositoryRequest, - dict, - ], -) -def test_get_repository(request_type, transport: str = "grpc"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # 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( - name="name_value", - format_=repository.Repository.Format.DOCKER, - description="description_value", - kms_key_name="kms_key_name_value", - maven_config=repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ), - ) - 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" - - -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=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_repository), "__call__") as call: - client.get_repository() + client.list_npm_packages() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == repository.GetRepositoryRequest() + assert args[0] == artifact.ListNpmPackagesRequest() @pytest.mark.asyncio -async def test_get_repository_async( - transport: str = "grpc_asyncio", request_type=repository.GetRepositoryRequest +async def test_list_npm_packages_async( + transport: str = "grpc_asyncio", request_type=artifact.ListNpmPackagesRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -2237,51 +2189,49 @@ async def test_get_repository_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_repository), "__call__") as call: + with mock.patch.object( + type(client.transport.list_npm_packages), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - repository.Repository( - name="name_value", - format_=repository.Repository.Format.DOCKER, - description="description_value", - kms_key_name="kms_key_name_value", + artifact.ListNpmPackagesResponse( + next_page_token="next_page_token_value", ) ) - response = await client.get_repository(request) + response = await client.list_npm_packages(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() + assert args[0] == artifact.ListNpmPackagesRequest() # 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" + assert isinstance(response, pagers.ListNpmPackagesAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_get_repository_async_from_dict(): - await test_get_repository_async(request_type=dict) +async def test_list_npm_packages_async_from_dict(): + await test_list_npm_packages_async(request_type=dict) -def test_get_repository_field_headers(): +def test_list_npm_packages_field_headers(): 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 = artifact.ListNpmPackagesRequest() - request.name = "name_value" + request.parent = "parent_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) + with mock.patch.object( + type(client.transport.list_npm_packages), "__call__" + ) as call: + call.return_value = artifact.ListNpmPackagesResponse() + client.list_npm_packages(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -2292,28 +2242,30 @@ def test_get_repository_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_repository_field_headers_async(): +async def test_list_npm_packages_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = artifact.ListNpmPackagesRequest() - request.name = "name_value" + request.parent = "parent_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: + with mock.patch.object( + type(client.transport.list_npm_packages), "__call__" + ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - repository.Repository() + artifact.ListNpmPackagesResponse() ) - await client.get_repository(request) + await client.list_npm_packages(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -2324,35 +2276,37 @@ async def test_get_repository_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] -def test_get_repository_flattened(): +def test_list_npm_packages_flattened(): 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: + with mock.patch.object( + type(client.transport.list_npm_packages), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = repository.Repository() + call.return_value = artifact.ListNpmPackagesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_repository( - name="name_value", + client.list_npm_packages( + parent="parent_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] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val -def test_get_repository_flattened_error(): +def test_list_npm_packages_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -2360,43 +2314,45 @@ def test_get_repository_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_repository( - repository.GetRepositoryRequest(), - name="name_value", + client.list_npm_packages( + artifact.ListNpmPackagesRequest(), + parent="parent_value", ) @pytest.mark.asyncio -async def test_get_repository_flattened_async(): +async def test_list_npm_packages_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object( + type(client.transport.list_npm_packages), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = repository.Repository() + call.return_value = artifact.ListNpmPackagesResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - repository.Repository() + artifact.ListNpmPackagesResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_repository( - name="name_value", + response = await client.list_npm_packages( + parent="parent_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val @pytest.mark.asyncio -async def test_get_repository_flattened_error_async(): +async def test_list_npm_packages_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -2404,23 +2360,219 @@ async def test_get_repository_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_repository( - repository.GetRepositoryRequest(), - name="name_value", + await client.list_npm_packages( + artifact.ListNpmPackagesRequest(), + parent="parent_value", ) -@pytest.mark.parametrize( - "request_type", - [ - gda_repository.CreateRepositoryRequest, - dict, - ], -) -def test_create_repository(request_type, transport: str = "grpc"): +def test_list_npm_packages_pager(transport_name: str = "grpc"): client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_npm_packages), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + artifact.NpmPackage(), + ], + next_page_token="abc", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[], + next_page_token="def", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + ], + next_page_token="ghi", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_npm_packages(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, artifact.NpmPackage) for i in results) + + +def test_list_npm_packages_pages(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_npm_packages), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + artifact.NpmPackage(), + ], + next_page_token="abc", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[], + next_page_token="def", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + ], + next_page_token="ghi", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + ], + ), + RuntimeError, + ) + pages = list(client.list_npm_packages(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_npm_packages_async_pager(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_npm_packages), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + artifact.NpmPackage(), + ], + next_page_token="abc", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[], + next_page_token="def", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + ], + next_page_token="ghi", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_npm_packages( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, artifact.NpmPackage) for i in responses) + + +@pytest.mark.asyncio +async def test_list_npm_packages_async_pages(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_npm_packages), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + artifact.NpmPackage(), + ], + next_page_token="abc", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[], + next_page_token="def", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + ], + next_page_token="ghi", + ), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_npm_packages(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.GetNpmPackageRequest, + dict, + ], +) +def test_get_npm_package(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2428,23 +2580,30 @@ def test_create_repository(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_repository), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_repository(request) + call.return_value = artifact.NpmPackage( + name="name_value", + package_name="package_name_value", + version="version_value", + tags=["tags_value"], + ) + response = client.get_npm_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] == gda_repository.CreateRepositoryRequest() + assert args[0] == artifact.GetNpmPackageRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, artifact.NpmPackage) + assert response.name == "name_value" + assert response.package_name == "package_name_value" + assert response.version == "version_value" + assert response.tags == ["tags_value"] -def test_create_repository_empty_call(): +def test_get_npm_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( @@ -2453,18 +2612,16 @@ def test_create_repository_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_repository), "__call__" - ) as call: - client.create_repository() + with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: + client.get_npm_package() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.CreateRepositoryRequest() + assert args[0] == artifact.GetNpmPackageRequest() @pytest.mark.asyncio -async def test_create_repository_async( - transport: str = "grpc_asyncio", request_type=gda_repository.CreateRepositoryRequest +async def test_get_npm_package_async( + transport: str = "grpc_asyncio", request_type=artifact.GetNpmPackageRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -2476,46 +2633,51 @@ async def test_create_repository_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_repository), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + artifact.NpmPackage( + name="name_value", + package_name="package_name_value", + version="version_value", + tags=["tags_value"], + ) ) - response = await client.create_repository(request) + response = await client.get_npm_package(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() + assert args[0] == artifact.GetNpmPackageRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, artifact.NpmPackage) + assert response.name == "name_value" + assert response.package_name == "package_name_value" + assert response.version == "version_value" + assert response.tags == ["tags_value"] @pytest.mark.asyncio -async def test_create_repository_async_from_dict(): - await test_create_repository_async(request_type=dict) +async def test_get_npm_package_async_from_dict(): + await test_get_npm_package_async(request_type=dict) -def test_create_repository_field_headers(): +def test_get_npm_package_field_headers(): 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 = artifact.GetNpmPackageRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_repository), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_repository(request) + with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: + call.return_value = artifact.NpmPackage() + client.get_npm_package(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -2526,30 +2688,26 @@ def test_create_repository_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_create_repository_field_headers_async(): +async def test_get_npm_package_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = artifact.GetNpmPackageRequest() - request.parent = "parent_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_repository), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.create_repository(request) + with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.NpmPackage()) + await client.get_npm_package(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -2560,53 +2718,35 @@ async def test_create_repository_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] -def test_create_repository_flattened(): +def test_get_npm_package_flattened(): 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_repository), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = artifact.NpmPackage() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_repository( - parent="parent_value", - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - repository_id="repository_id_value", + client.get_npm_package( + name="name_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] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - arg = args[0].repository - mock_val = gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ) - assert arg == mock_val - arg = args[0].repository_id - mock_val = "repository_id_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_create_repository_flattened_error(): +def test_get_npm_package_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -2614,67 +2754,41 @@ def test_create_repository_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_repository( - gda_repository.CreateRepositoryRequest(), - parent="parent_value", - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - repository_id="repository_id_value", + client.get_npm_package( + artifact.GetNpmPackageRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_create_repository_flattened_async(): +async def test_get_npm_package_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_repository), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = artifact.NpmPackage() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.NpmPackage()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_repository( - parent="parent_value", - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - repository_id="repository_id_value", + response = await client.get_npm_package( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - arg = args[0].repository - mock_val = gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ) - assert arg == mock_val - arg = args[0].repository_id - mock_val = "repository_id_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_create_repository_flattened_error_async(): +async def test_get_npm_package_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -2682,26 +2796,20 @@ async def test_create_repository_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.create_repository( - gda_repository.CreateRepositoryRequest(), - parent="parent_value", - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - repository_id="repository_id_value", + await client.get_npm_package( + artifact.GetNpmPackageRequest(), + name="name_value", ) @pytest.mark.parametrize( "request_type", [ - gda_repository.UpdateRepositoryRequest, + artifact.ListPythonPackagesRequest, dict, ], ) -def test_update_repository(request_type, transport: str = "grpc"): +def test_list_python_packages(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -2713,34 +2821,25 @@ def test_update_repository(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = gda_repository.Repository( - name="name_value", - format_=gda_repository.Repository.Format.DOCKER, - description="description_value", - kms_key_name="kms_key_name_value", - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ), + call.return_value = artifact.ListPythonPackagesResponse( + next_page_token="next_page_token_value", ) - response = client.update_repository(request) + response = client.list_python_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] == gda_repository.UpdateRepositoryRequest() + assert args[0] == artifact.ListPythonPackagesRequest() # 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" + assert isinstance(response, pagers.ListPythonPackagesPager) + assert response.next_page_token == "next_page_token_value" -def test_update_repository_empty_call(): +def test_list_python_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( @@ -2750,17 +2849,17 @@ def test_update_repository_empty_call(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: - client.update_repository() + client.list_python_packages() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.UpdateRepositoryRequest() + assert args[0] == artifact.ListPythonPackagesRequest() @pytest.mark.asyncio -async def test_update_repository_async( - transport: str = "grpc_asyncio", request_type=gda_repository.UpdateRepositoryRequest +async def test_list_python_packages_async( + transport: str = "grpc_asyncio", request_type=artifact.ListPythonPackagesRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -2773,54 +2872,48 @@ async def test_update_repository_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gda_repository.Repository( - name="name_value", - format_=gda_repository.Repository.Format.DOCKER, - description="description_value", - kms_key_name="kms_key_name_value", + artifact.ListPythonPackagesResponse( + next_page_token="next_page_token_value", ) ) - response = await client.update_repository(request) + response = await client.list_python_packages(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() + assert args[0] == artifact.ListPythonPackagesRequest() # 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" + assert isinstance(response, pagers.ListPythonPackagesAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_update_repository_async_from_dict(): - await test_update_repository_async(request_type=dict) +async def test_list_python_packages_async_from_dict(): + await test_list_python_packages_async(request_type=dict) -def test_update_repository_field_headers(): +def test_list_python_packages_field_headers(): 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 = artifact.ListPythonPackagesRequest() - request.repository.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: - call.return_value = gda_repository.Repository() - client.update_repository(request) + call.return_value = artifact.ListPythonPackagesResponse() + client.list_python_packages(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -2831,30 +2924,30 @@ def test_update_repository_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "repository.name=name_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_repository_field_headers_async(): +async def test_list_python_packages_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = artifact.ListPythonPackagesRequest() - request.repository.name = "name_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gda_repository.Repository() + artifact.ListPythonPackagesResponse() ) - await client.update_repository(request) + await client.list_python_packages(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -2865,49 +2958,37 @@ async def test_update_repository_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "repository.name=name_value", + "parent=parent_value", ) in kw["metadata"] -def test_update_repository_flattened(): +def test_list_python_packages_flattened(): 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_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = gda_repository.Repository() + call.return_value = artifact.ListPythonPackagesResponse() # 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( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.list_python_packages( + parent="parent_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] - arg = args[0].repository - mock_val = gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ) - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val -def test_update_repository_flattened_error(): +def test_list_python_packages_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -2915,62 +2996,45 @@ def test_update_repository_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_repository( - gda_repository.UpdateRepositoryRequest(), - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.list_python_packages( + artifact.ListPythonPackagesRequest(), + parent="parent_value", ) @pytest.mark.asyncio -async def test_update_repository_flattened_async(): +async def test_list_python_packages_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = gda_repository.Repository() + call.return_value = artifact.ListPythonPackagesResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gda_repository.Repository() + artifact.ListPythonPackagesResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.update_repository( - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + response = await client.list_python_packages( + parent="parent_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].repository - mock_val = gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ) - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val @pytest.mark.asyncio -async def test_update_repository_flattened_error_async(): +async def test_list_python_packages_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -2978,123 +3042,332 @@ async def test_update_repository_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.update_repository( - gda_repository.UpdateRepositoryRequest(), - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + await client.list_python_packages( + artifact.ListPythonPackagesRequest(), + parent="parent_value", ) -@pytest.mark.parametrize( - "request_type", - [ - repository.DeleteRepositoryRequest, - dict, - ], -) -def test_delete_repository(request_type, transport: str = "grpc"): +def test_list_python_packages_pager(transport_name: str = "grpc"): client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_repository(request) + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + artifact.PythonPackage(), + artifact.PythonPackage(), + ], + next_page_token="abc", + ), + artifact.ListPythonPackagesResponse( + python_packages=[], + next_page_token="def", + ), + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + ], + next_page_token="ghi", + ), + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + artifact.PythonPackage(), + ], + ), + RuntimeError, + ) - # 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() + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_python_packages(request={}) - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert pager._metadata == metadata + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, artifact.PythonPackage) for i in results) -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. + +def test_list_python_packages_pages(transport_name: str = "grpc"): client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.list_python_packages), "__call__" ) as call: - client.delete_repository() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == repository.DeleteRepositoryRequest() + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + artifact.PythonPackage(), + artifact.PythonPackage(), + ], + next_page_token="abc", + ), + artifact.ListPythonPackagesResponse( + python_packages=[], + next_page_token="def", + ), + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + ], + next_page_token="ghi", + ), + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + artifact.PythonPackage(), + ], + ), + RuntimeError, + ) + pages = list(client.list_python_packages(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.asyncio -async def test_delete_repository_async( - transport: str = "grpc_asyncio", request_type=repository.DeleteRepositoryRequest -): +async def test_list_python_packages_async_pager(): client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.list_python_packages), + "__call__", + new_callable=mock.AsyncMock, ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + artifact.PythonPackage(), + artifact.PythonPackage(), + ], + next_page_token="abc", + ), + artifact.ListPythonPackagesResponse( + python_packages=[], + next_page_token="def", + ), + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + ], + next_page_token="ghi", + ), + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + artifact.PythonPackage(), + ], + ), + RuntimeError, ) - response = await client.delete_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) + async_pager = await client.list_python_packages( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, artifact.PythonPackage) for i in responses) + + +@pytest.mark.asyncio +async def test_list_python_packages_async_pages(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_python_packages), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + artifact.PythonPackage(), + artifact.PythonPackage(), + ], + next_page_token="abc", + ), + artifact.ListPythonPackagesResponse( + python_packages=[], + next_page_token="def", + ), + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + ], + next_page_token="ghi", + ), + artifact.ListPythonPackagesResponse( + python_packages=[ + artifact.PythonPackage(), + artifact.PythonPackage(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_python_packages(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.GetPythonPackageRequest, + dict, + ], +) +def test_get_python_package(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_python_package), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = artifact.PythonPackage( + name="name_value", + uri="uri_value", + package_name="package_name_value", + version="version_value", + ) + response = client.get_python_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] == repository.DeleteRepositoryRequest() + assert args[0] == artifact.GetPythonPackageRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, artifact.PythonPackage) + assert response.name == "name_value" + assert response.uri == "uri_value" + assert response.package_name == "package_name_value" + assert response.version == "version_value" + + +def test_get_python_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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_python_package), "__call__" + ) as call: + client.get_python_package() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == artifact.GetPythonPackageRequest() @pytest.mark.asyncio -async def test_delete_repository_async_from_dict(): - await test_delete_repository_async(request_type=dict) +async def test_get_python_package_async( + transport: str = "grpc_asyncio", request_type=artifact.GetPythonPackageRequest +): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_python_package), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + artifact.PythonPackage( + name="name_value", + uri="uri_value", + package_name="package_name_value", + version="version_value", + ) + ) + response = await client.get_python_package(request) -def test_delete_repository_field_headers(): + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == artifact.GetPythonPackageRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, artifact.PythonPackage) + assert response.name == "name_value" + assert response.uri == "uri_value" + assert response.package_name == "package_name_value" + assert response.version == "version_value" + + +@pytest.mark.asyncio +async def test_get_python_package_async_from_dict(): + await test_get_python_package_async(request_type=dict) + + +def test_get_python_package_field_headers(): 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 = artifact.GetPythonPackageRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.get_python_package), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_repository(request) + call.return_value = artifact.PythonPackage() + client.get_python_package(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -3110,25 +3383,25 @@ def test_delete_repository_field_headers(): @pytest.mark.asyncio -async def test_delete_repository_field_headers_async(): +async def test_get_python_package_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = artifact.GetPythonPackageRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.get_python_package), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") + artifact.PythonPackage() ) - await client.delete_repository(request) + await client.get_python_package(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -3143,20 +3416,20 @@ async def test_delete_repository_field_headers_async(): ) in kw["metadata"] -def test_delete_repository_flattened(): +def test_get_python_package_flattened(): 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_repository), "__call__" + type(client.transport.get_python_package), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = artifact.PythonPackage() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_repository( + client.get_python_package( name="name_value", ) @@ -3169,7 +3442,7 @@ def test_delete_repository_flattened(): assert arg == mock_val -def test_delete_repository_flattened_error(): +def test_get_python_package_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -3177,31 +3450,31 @@ def test_delete_repository_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_repository( - repository.DeleteRepositoryRequest(), + client.get_python_package( + artifact.GetPythonPackageRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_delete_repository_flattened_async(): +async def test_get_python_package_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.get_python_package), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = artifact.PythonPackage() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + artifact.PythonPackage() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_repository( + response = await client.get_python_package( name="name_value", ) @@ -3215,7 +3488,7 @@ async def test_delete_repository_flattened_async(): @pytest.mark.asyncio -async def test_delete_repository_flattened_error_async(): +async def test_get_python_package_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -3223,8 +3496,8 @@ async def test_delete_repository_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.delete_repository( - repository.DeleteRepositoryRequest(), + await client.get_python_package( + artifact.GetPythonPackageRequest(), name="name_value", ) @@ -3232,11 +3505,11 @@ async def test_delete_repository_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - package.ListPackagesRequest, + apt_artifact.ImportAptArtifactsRequest, dict, ], ) -def test_list_packages(request_type, transport: str = "grpc"): +def test_import_apt_artifacts(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3247,24 +3520,23 @@ def test_list_packages(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_packages), "__call__") as call: + with mock.patch.object( + type(client.transport.import_apt_artifacts), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = package.ListPackagesResponse( - next_page_token="next_page_token_value", - ) - response = client.list_packages(request) + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.import_apt_artifacts(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() + assert args[0] == apt_artifact.ImportAptArtifactsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPackagesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, future.Future) -def test_list_packages_empty_call(): +def test_import_apt_artifacts_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( @@ -3273,16 +3545,18 @@ def test_list_packages_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_packages), "__call__") as call: - client.list_packages() + with mock.patch.object( + type(client.transport.import_apt_artifacts), "__call__" + ) as call: + client.import_apt_artifacts() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == package.ListPackagesRequest() + assert args[0] == apt_artifact.ImportAptArtifactsRequest() @pytest.mark.asyncio -async def test_list_packages_async( - transport: str = "grpc_asyncio", request_type=package.ListPackagesRequest +async def test_import_apt_artifacts_async( + transport: str = "grpc_asyncio", request_type=apt_artifact.ImportAptArtifactsRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -3294,45 +3568,46 @@ async def test_list_packages_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_packages), "__call__") as call: + with mock.patch.object( + type(client.transport.import_apt_artifacts), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - package.ListPackagesResponse( - next_page_token="next_page_token_value", - ) + operations_pb2.Operation(name="operations/spam") ) - response = await client.list_packages(request) + response = await client.import_apt_artifacts(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() + assert args[0] == apt_artifact.ImportAptArtifactsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPackagesAsyncPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_list_packages_async_from_dict(): - await test_list_packages_async(request_type=dict) +async def test_import_apt_artifacts_async_from_dict(): + await test_import_apt_artifacts_async(request_type=dict) -def test_list_packages_field_headers(): +def test_import_apt_artifacts_field_headers(): 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 = apt_artifact.ImportAptArtifactsRequest() 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) + with mock.patch.object( + type(client.transport.import_apt_artifacts), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.import_apt_artifacts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -3348,23 +3623,25 @@ def test_list_packages_field_headers(): @pytest.mark.asyncio -async def test_list_packages_field_headers_async(): +async def test_import_apt_artifacts_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = apt_artifact.ImportAptArtifactsRequest() 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: + with mock.patch.object( + type(client.transport.import_apt_artifacts), "__call__" + ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - package.ListPackagesResponse() + operations_pb2.Operation(name="operations/op") ) - await client.list_packages(request) + await client.import_apt_artifacts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -3379,270 +3656,596 @@ async def test_list_packages_field_headers_async(): ) in kw["metadata"] -def test_list_packages_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + yum_artifact.ImportYumArtifactsRequest, + dict, + ], +) +def test_import_yum_artifacts(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_packages), "__call__") as call: + with mock.patch.object( + type(client.transport.import_yum_artifacts), "__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", - ) + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.import_yum_artifacts(request) - # Establish that the underlying call was made with the expected - # request object values. + # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - + assert args[0] == yum_artifact.ImportYumArtifactsRequest() -def test_list_packages_flattened_error(): + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_import_yum_artifacts_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=ga_credentials.AnonymousCredentials(), + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_packages( - package.ListPackagesRequest(), - parent="parent_value", - ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.import_yum_artifacts), "__call__" + ) as call: + client.import_yum_artifacts() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == yum_artifact.ImportYumArtifactsRequest() @pytest.mark.asyncio -async def test_list_packages_flattened_async(): +async def test_import_yum_artifacts_async( + transport: str = "grpc_asyncio", request_type=yum_artifact.ImportYumArtifactsRequest +): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_packages), "__call__") as call: + with mock.patch.object( + type(client.transport.import_yum_artifacts), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = package.ListPackagesResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - package.ListPackagesResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_packages( - parent="parent_value", + operations_pb2.Operation(name="operations/spam") ) + response = await client.import_yum_artifacts(request) - # Establish that the underlying call was made with the expected - # request object values. + # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val + assert args[0] == yum_artifact.ImportYumArtifactsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_list_packages_flattened_error_async(): +async def test_import_yum_artifacts_async_from_dict(): + await test_import_yum_artifacts_async(request_type=dict) + + +def test_import_yum_artifacts_field_headers(): + 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 = yum_artifact.ImportYumArtifactsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.import_yum_artifacts), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.import_yum_artifacts(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_import_yum_artifacts_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_packages( - package.ListPackagesRequest(), - parent="parent_value", + # 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 = yum_artifact.ImportYumArtifactsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.import_yum_artifacts), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") ) + await client.import_yum_artifacts(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request -def test_list_packages_pager(transport_name: str = "grpc"): + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.parametrize( + "request_type", + [ + repository.ListRepositoriesRequest, + dict, + ], +) +def test_list_repositories(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_packages), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - package.ListPackagesResponse( - packages=[ - package.Package(), - package.Package(), - package.Package(), - ], - next_page_token="abc", - ), - package.ListPackagesResponse( - packages=[], - next_page_token="def", - ), - package.ListPackagesResponse( - packages=[ - package.Package(), - ], - next_page_token="ghi", - ), - package.ListPackagesResponse( - packages=[ - package.Package(), - package.Package(), - ], - ), - RuntimeError, - ) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_repositories), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = repository.ListRepositoriesResponse( + next_page_token="next_page_token_value", ) - pager = client.list_packages(request={}) + response = client.list_repositories(request) - assert pager._metadata == metadata + # 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() - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, package.Package) for i in results) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListRepositoriesPager) + assert response.next_page_token == "next_page_token_value" -def test_list_packages_pages(transport_name: str = "grpc"): +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=ga_credentials.AnonymousCredentials, - transport=transport_name, + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_packages), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - package.ListPackagesResponse( - packages=[ - package.Package(), - package.Package(), - package.Package(), - ], - next_page_token="abc", - ), - package.ListPackagesResponse( - packages=[], - next_page_token="def", - ), - package.ListPackagesResponse( - packages=[ - package.Package(), - ], - next_page_token="ghi", - ), - package.ListPackagesResponse( - packages=[ - package.Package(), - package.Package(), - ], - ), - RuntimeError, - ) - pages = list(client.list_packages(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + with mock.patch.object( + type(client.transport.list_repositories), "__call__" + ) as call: + client.list_repositories() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == repository.ListRepositoriesRequest() @pytest.mark.asyncio -async def test_list_packages_async_pager(): +async def test_list_repositories_async( + transport: str = "grpc_asyncio", request_type=repository.ListRepositoriesRequest +): client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_packages), "__call__", new_callable=mock.AsyncMock + type(client.transport.list_repositories), "__call__" ) as call: - # Set the response to a series of pages. + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + repository.ListRepositoriesResponse( + 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" + + +@pytest.mark.asyncio +async def test_list_repositories_async_from_dict(): + await test_list_repositories_async(request_type=dict) + + +def test_list_repositories_field_headers(): + 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. + with mock.patch.object( + 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. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_repositories_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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. + with mock.patch.object( + type(client.transport.list_repositories), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + repository.ListRepositoriesResponse() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_repositories_flattened(): + 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_repositories), "__call__" + ) 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", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_repositories_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_repositories( + repository.ListRepositoriesRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_repositories_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_repositories), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = repository.ListRepositoriesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + repository.ListRepositoriesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_repositories( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_repositories_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_repositories( + repository.ListRepositoriesRequest(), + parent="parent_value", + ) + + +def test_list_repositories_pager(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_repositories), "__call__" + ) as call: + # Set the response to a series of pages. call.side_effect = ( - package.ListPackagesResponse( - packages=[ - package.Package(), - package.Package(), - package.Package(), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + repository.Repository(), + repository.Repository(), ], next_page_token="abc", ), - package.ListPackagesResponse( - packages=[], + repository.ListRepositoriesResponse( + repositories=[], next_page_token="def", ), - package.ListPackagesResponse( - packages=[ - package.Package(), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), ], next_page_token="ghi", ), - package.ListPackagesResponse( - packages=[ - package.Package(), - package.Package(), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + repository.Repository(), ], ), RuntimeError, ) - async_pager = await client.list_packages( - request={}, + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) + pager = client.list_repositories(request={}) - assert len(responses) == 6 - assert all(isinstance(i, package.Package) for i in responses) + assert pager._metadata == metadata + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, repository.Repository) for i in results) -@pytest.mark.asyncio -async def test_list_packages_async_pages(): - client = ArtifactRegistryAsyncClient( + +def test_list_repositories_pages(transport_name: str = "grpc"): + client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_packages), "__call__", new_callable=mock.AsyncMock + type(client.transport.list_repositories), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( - package.ListPackagesResponse( - packages=[ - package.Package(), - package.Package(), - package.Package(), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + repository.Repository(), + repository.Repository(), ], next_page_token="abc", ), - package.ListPackagesResponse( - packages=[], + repository.ListRepositoriesResponse( + repositories=[], next_page_token="def", ), - package.ListPackagesResponse( - packages=[ - package.Package(), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), ], next_page_token="ghi", ), - package.ListPackagesResponse( - packages=[ - package.Package(), - package.Package(), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + repository.Repository(), + ], + ), + RuntimeError, + ) + pages = list(client.list_repositories(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_repositories_async_pager(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_repositories), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + repository.Repository(), + repository.Repository(), + ], + next_page_token="abc", + ), + repository.ListRepositoriesResponse( + repositories=[], + next_page_token="def", + ), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + ], + next_page_token="ghi", + ), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + repository.Repository(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_repositories( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, repository.Repository) for i in responses) + + +@pytest.mark.asyncio +async def test_list_repositories_async_pages(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_repositories), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + repository.Repository(), + repository.Repository(), + ], + next_page_token="abc", + ), + repository.ListRepositoriesResponse( + repositories=[], + next_page_token="def", + ), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + ], + next_page_token="ghi", + ), + repository.ListRepositoriesResponse( + repositories=[ + repository.Repository(), + repository.Repository(), ], ), RuntimeError, ) pages = [] async for page_ in ( - await client.list_packages(request={}) + await client.list_repositories(request={}) ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): @@ -3652,11 +4255,1955 @@ async def test_list_packages_async_pages(): @pytest.mark.parametrize( "request_type", [ - package.GetPackageRequest, + repository.GetRepositoryRequest, + dict, + ], +) +def test_get_repository(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # 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( + name="name_value", + format_=repository.Repository.Format.DOCKER, + description="description_value", + kms_key_name="kms_key_name_value", + maven_config=repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ), + ) + 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" + + +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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_repository), "__call__") as call: + client.get_repository() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == repository.GetRepositoryRequest() + + +@pytest.mark.asyncio +async def test_get_repository_async( + transport: str = "grpc_asyncio", request_type=repository.GetRepositoryRequest +): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # 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 = grpc_helpers_async.FakeUnaryUnaryCall( + repository.Repository( + name="name_value", + format_=repository.Repository.Format.DOCKER, + description="description_value", + 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" + + +@pytest.mark.asyncio +async def test_get_repository_async_from_dict(): + await test_get_repository_async(request_type=dict) + + +def test_get_repository_field_headers(): + 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. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_repository_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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 = grpc_helpers_async.FakeUnaryUnaryCall( + repository.Repository() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_repository_flattened(): + 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", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_repository_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_repository( + repository.GetRepositoryRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_repository_flattened_async(): + client = ArtifactRegistryAsyncClient( + 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.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + repository.Repository() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_repository( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_repository_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_repository( + repository.GetRepositoryRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + gda_repository.CreateRepositoryRequest, + dict, + ], +) +def test_create_repository(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_repository), "__call__" + ) 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. + assert isinstance(response, future.Future) + + +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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_repository), "__call__" + ) as call: + client.create_repository() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gda_repository.CreateRepositoryRequest() + + +@pytest.mark.asyncio +async def test_create_repository_async( + transport: str = "grpc_asyncio", request_type=gda_repository.CreateRepositoryRequest +): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + 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. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_repository_async_from_dict(): + await test_create_repository_async(request_type=dict) + + +def test_create_repository_field_headers(): + 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. + with mock.patch.object( + 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. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_repository_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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. + with mock.patch.object( + type(client.transport.create_repository), "__call__" + ) as call: + 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. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_repository_flattened(): + 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_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_repository( + parent="parent_value", + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + repository_id="repository_id_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] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].repository + mock_val = gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ) + assert arg == mock_val + arg = args[0].repository_id + mock_val = "repository_id_value" + assert arg == mock_val + + +def test_create_repository_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_repository( + gda_repository.CreateRepositoryRequest(), + parent="parent_value", + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + repository_id="repository_id_value", + ) + + +@pytest.mark.asyncio +async def test_create_repository_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_repository( + parent="parent_value", + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + repository_id="repository_id_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].repository + mock_val = gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ) + assert arg == mock_val + arg = args[0].repository_id + mock_val = "repository_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_repository_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_repository( + gda_repository.CreateRepositoryRequest(), + parent="parent_value", + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + repository_id="repository_id_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + gda_repository.UpdateRepositoryRequest, + dict, + ], +) +def test_update_repository(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gda_repository.Repository( + name="name_value", + format_=gda_repository.Repository.Format.DOCKER, + description="description_value", + kms_key_name="kms_key_name_value", + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ), + ) + 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" + + +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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_repository), "__call__" + ) as call: + client.update_repository() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gda_repository.UpdateRepositoryRequest() + + +@pytest.mark.asyncio +async def test_update_repository_async( + transport: str = "grpc_asyncio", request_type=gda_repository.UpdateRepositoryRequest +): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_repository.Repository( + name="name_value", + format_=gda_repository.Repository.Format.DOCKER, + description="description_value", + 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" + + +@pytest.mark.asyncio +async def test_update_repository_async_from_dict(): + await test_update_repository_async(request_type=dict) + + +def test_update_repository_field_headers(): + 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 = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + 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. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "repository.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_repository_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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 = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_repository), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_repository.Repository() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "repository.name=name_value", + ) in kw["metadata"] + + +def test_update_repository_flattened(): + 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_repository), "__call__" + ) 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( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + 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] + arg = args[0].repository + mock_val = gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ) + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_repository_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_repository( + gda_repository.UpdateRepositoryRequest(), + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_repository_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gda_repository.Repository() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_repository.Repository() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_repository( + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + 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] + arg = args[0].repository + mock_val = gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ) + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_repository_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_repository( + gda_repository.UpdateRepositoryRequest(), + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + repository.DeleteRepositoryRequest, + dict, + ], +) +def test_delete_repository(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_repository), "__call__" + ) 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. + assert isinstance(response, future.Future) + + +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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_repository), "__call__" + ) as call: + client.delete_repository() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == repository.DeleteRepositoryRequest() + + +@pytest.mark.asyncio +async def test_delete_repository_async( + transport: str = "grpc_asyncio", request_type=repository.DeleteRepositoryRequest +): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + 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. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_repository_async_from_dict(): + await test_delete_repository_async(request_type=dict) + + +def test_delete_repository_field_headers(): + 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. + with mock.patch.object( + 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. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_repository_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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. + with mock.patch.object( + type(client.transport.delete_repository), "__call__" + ) as call: + 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. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_repository_flattened(): + 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_repository), "__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_repository( + name="name_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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_repository_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_repository( + repository.DeleteRepositoryRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_repository_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_repository( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_repository_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_repository( + repository.DeleteRepositoryRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + package.ListPackagesRequest, + dict, + ], +) +def test_list_packages(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # 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( + 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" + + +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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_packages), "__call__") as call: + client.list_packages() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == package.ListPackagesRequest() + + +@pytest.mark.asyncio +async def test_list_packages_async( + transport: str = "grpc_asyncio", request_type=package.ListPackagesRequest +): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # 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 = 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" + + +@pytest.mark.asyncio +async def test_list_packages_async_from_dict(): + await test_list_packages_async(request_type=dict) + + +def test_list_packages_field_headers(): + 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. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_packages_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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 = grpc_helpers_async.FakeUnaryUnaryCall( + package.ListPackagesResponse() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_packages_flattened(): + 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", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_packages_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_packages( + package.ListPackagesRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_packages_flattened_async(): + client = ArtifactRegistryAsyncClient( + 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.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + package.ListPackagesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_packages( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_packages_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_packages( + package.ListPackagesRequest(), + parent="parent_value", + ) + + +def test_list_packages_pager(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_packages), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + package.ListPackagesResponse( + packages=[ + package.Package(), + package.Package(), + package.Package(), + ], + next_page_token="abc", + ), + package.ListPackagesResponse( + packages=[], + next_page_token="def", + ), + package.ListPackagesResponse( + packages=[ + package.Package(), + ], + next_page_token="ghi", + ), + package.ListPackagesResponse( + packages=[ + package.Package(), + package.Package(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_packages(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, package.Package) for i in results) + + +def test_list_packages_pages(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_packages), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + package.ListPackagesResponse( + packages=[ + package.Package(), + package.Package(), + package.Package(), + ], + next_page_token="abc", + ), + package.ListPackagesResponse( + packages=[], + next_page_token="def", + ), + package.ListPackagesResponse( + packages=[ + package.Package(), + ], + next_page_token="ghi", + ), + package.ListPackagesResponse( + packages=[ + package.Package(), + package.Package(), + ], + ), + RuntimeError, + ) + pages = list(client.list_packages(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_packages_async_pager(): + client = ArtifactRegistryAsyncClient( + 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__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + package.ListPackagesResponse( + packages=[ + package.Package(), + package.Package(), + package.Package(), + ], + next_page_token="abc", + ), + package.ListPackagesResponse( + packages=[], + next_page_token="def", + ), + package.ListPackagesResponse( + packages=[ + package.Package(), + ], + next_page_token="ghi", + ), + package.ListPackagesResponse( + packages=[ + package.Package(), + package.Package(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_packages( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, package.Package) for i in responses) + + +@pytest.mark.asyncio +async def test_list_packages_async_pages(): + client = ArtifactRegistryAsyncClient( + 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__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + package.ListPackagesResponse( + packages=[ + package.Package(), + package.Package(), + package.Package(), + ], + next_page_token="abc", + ), + package.ListPackagesResponse( + packages=[], + next_page_token="def", + ), + package.ListPackagesResponse( + packages=[ + package.Package(), + ], + next_page_token="ghi", + ), + package.ListPackagesResponse( + packages=[ + package.Package(), + package.Package(), + ], + ), + RuntimeError, + ) + pages = [] + async for page_ in ( + await client.list_packages(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + package.GetPackageRequest, + dict, + ], +) +def test_get_package(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # 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( + 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" + + +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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_package), "__call__") as call: + client.get_package() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == package.GetPackageRequest() + + +@pytest.mark.asyncio +async def test_get_package_async( + transport: str = "grpc_asyncio", request_type=package.GetPackageRequest +): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # 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 = 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" + + +@pytest.mark.asyncio +async def test_get_package_async_from_dict(): + await test_get_package_async(request_type=dict) + + +def test_get_package_field_headers(): + 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. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_package_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_package_flattened(): + 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", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_package_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_package( + package.GetPackageRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_package_flattened_async(): + client = ArtifactRegistryAsyncClient( + 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.return_value = grpc_helpers_async.FakeUnaryUnaryCall(package.Package()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_package( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_package_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_package( + package.GetPackageRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + package.DeletePackageRequest, + dict, + ], +) +def test_delete_package(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # 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/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. + assert isinstance(response, future.Future) + + +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=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_package), "__call__") as call: + client.delete_package() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == package.DeletePackageRequest() + + +@pytest.mark.asyncio +async def test_delete_package_async( + transport: str = "grpc_asyncio", request_type=package.DeletePackageRequest +): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # 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 = 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. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_package_async_from_dict(): + await test_delete_package_async(request_type=dict) + + +def test_delete_package_field_headers(): + 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. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_package_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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 = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_package_flattened(): + 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", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_package_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_package( + package.DeletePackageRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_package_flattened_async(): + client = ArtifactRegistryAsyncClient( + 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.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_package( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_package_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_package( + package.DeletePackageRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + version.ListVersionsRequest, dict, ], ) -def test_get_package(request_type, transport: str = "grpc"): +def test_list_versions(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3667,26 +6214,24 @@ def test_get_package(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_package), "__call__") as call: + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = package.Package( - name="name_value", - display_name="display_name_value", + call.return_value = version.ListVersionsResponse( + next_page_token="next_page_token_value", ) - response = client.get_package(request) + 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] == package.GetPackageRequest() + assert args[0] == version.ListVersionsRequest() # 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" + assert isinstance(response, pagers.ListVersionsPager) + assert response.next_page_token == "next_page_token_value" -def test_get_package_empty_call(): +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( @@ -3695,16 +6240,16 @@ def test_get_package_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_package), "__call__") as call: - client.get_package() + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: + client.list_versions() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == package.GetPackageRequest() + assert args[0] == version.ListVersionsRequest() @pytest.mark.asyncio -async def test_get_package_async( - transport: str = "grpc_asyncio", request_type=package.GetPackageRequest +async def test_list_versions_async( + transport: str = "grpc_asyncio", request_type=version.ListVersionsRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -3716,47 +6261,45 @@ async def test_get_package_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_package), "__call__") as call: + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - package.Package( - name="name_value", - display_name="display_name_value", + version.ListVersionsResponse( + next_page_token="next_page_token_value", ) ) - response = await client.get_package(request) + 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] == package.GetPackageRequest() + assert args[0] == version.ListVersionsRequest() # 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" + assert isinstance(response, pagers.ListVersionsAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_get_package_async_from_dict(): - await test_get_package_async(request_type=dict) +async def test_list_versions_async_from_dict(): + await test_list_versions_async(request_type=dict) -def test_get_package_field_headers(): +def test_list_versions_field_headers(): 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 = version.ListVersionsRequest() - request.name = "name_value" + request.parent = "parent_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) + 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. assert len(call.mock_calls) == 1 @@ -3767,26 +6310,28 @@ def test_get_package_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_package_field_headers_async(): +async def test_list_versions_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = version.ListVersionsRequest() - request.name = "name_value" + request.parent = "parent_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) + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + version.ListVersionsResponse() + ) + await client.list_versions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -3797,35 +6342,35 @@ async def test_get_package_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] -def test_get_package_flattened(): +def test_list_versions_flattened(): 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: + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = package.Package() + call.return_value = version.ListVersionsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_package( - name="name_value", + client.list_versions( + parent="parent_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] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val -def test_get_package_flattened_error(): +def test_list_versions_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -3833,62 +6378,252 @@ def test_get_package_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_package( - package.GetPackageRequest(), - name="name_value", + client.list_versions( + version.ListVersionsRequest(), + parent="parent_value", ) @pytest.mark.asyncio -async def test_get_package_flattened_async(): +async def test_list_versions_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = package.Package() + call.return_value = version.ListVersionsResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(package.Package()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + version.ListVersionsResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_package( - name="name_value", + response = await client.list_versions( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_versions_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_versions( + version.ListVersionsRequest(), + parent="parent_value", + ) + + +def test_list_versions_pager(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + version.ListVersionsResponse( + versions=[ + version.Version(), + version.Version(), + version.Version(), + ], + next_page_token="abc", + ), + version.ListVersionsResponse( + versions=[], + next_page_token="def", + ), + version.ListVersionsResponse( + versions=[ + version.Version(), + ], + next_page_token="ghi", + ), + version.ListVersionsResponse( + versions=[ + version.Version(), + version.Version(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_versions(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, version.Version) for i in results) + + +def test_list_versions_pages(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + version.ListVersionsResponse( + versions=[ + version.Version(), + version.Version(), + version.Version(), + ], + next_page_token="abc", + ), + version.ListVersionsResponse( + versions=[], + next_page_token="def", + ), + version.ListVersionsResponse( + versions=[ + version.Version(), + ], + next_page_token="ghi", + ), + version.ListVersionsResponse( + versions=[ + version.Version(), + version.Version(), + ], + ), + RuntimeError, + ) + pages = list(client.list_versions(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_versions_async_pager(): + client = ArtifactRegistryAsyncClient( + 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__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + version.ListVersionsResponse( + versions=[ + version.Version(), + version.Version(), + version.Version(), + ], + next_page_token="abc", + ), + version.ListVersionsResponse( + versions=[], + next_page_token="def", + ), + version.ListVersionsResponse( + versions=[ + version.Version(), + ], + next_page_token="ghi", + ), + version.ListVersionsResponse( + versions=[ + version.Version(), + version.Version(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_versions( + request={}, ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val + assert len(responses) == 6 + assert all(isinstance(i, version.Version) for i in responses) @pytest.mark.asyncio -async def test_get_package_flattened_error_async(): +async def test_list_versions_async_pages(): client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_package( - package.GetPackageRequest(), - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_versions), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + version.ListVersionsResponse( + versions=[ + version.Version(), + version.Version(), + version.Version(), + ], + next_page_token="abc", + ), + version.ListVersionsResponse( + versions=[], + next_page_token="def", + ), + version.ListVersionsResponse( + versions=[ + version.Version(), + ], + next_page_token="ghi", + ), + version.ListVersionsResponse( + versions=[ + version.Version(), + version.Version(), + ], + ), + RuntimeError, ) + pages = [] + async for page_ in ( + await client.list_versions(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - package.DeletePackageRequest, + version.GetVersionRequest, dict, ], ) -def test_delete_package(request_type, transport: str = "grpc"): +def test_get_version(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3899,21 +6634,26 @@ def test_delete_package(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_package), "__call__") as call: + with mock.patch.object(type(client.transport.get_version), "__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) + 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] == package.DeletePackageRequest() + assert args[0] == version.GetVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, version.Version) + assert response.name == "name_value" + assert response.description == "description_value" -def test_delete_package_empty_call(): +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( @@ -3922,16 +6662,16 @@ def test_delete_package_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_package), "__call__") as call: - client.delete_package() + with mock.patch.object(type(client.transport.get_version), "__call__") as call: + client.get_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == package.DeletePackageRequest() + assert args[0] == version.GetVersionRequest() @pytest.mark.asyncio -async def test_delete_package_async( - transport: str = "grpc_asyncio", request_type=package.DeletePackageRequest +async def test_get_version_async( + transport: str = "grpc_asyncio", request_type=version.GetVersionRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -3943,42 +6683,47 @@ async def test_delete_package_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_package), "__call__") as call: + with mock.patch.object(type(client.transport.get_version), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + version.Version( + name="name_value", + description="description_value", + ) ) - response = await client.delete_package(request) + 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] == package.DeletePackageRequest() + assert args[0] == version.GetVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, version.Version) + assert response.name == "name_value" + assert response.description == "description_value" @pytest.mark.asyncio -async def test_delete_package_async_from_dict(): - await test_delete_package_async(request_type=dict) +async def test_get_version_async_from_dict(): + await test_get_version_async(request_type=dict) -def test_delete_package_field_headers(): +def test_get_version_field_headers(): 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 = 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.delete_package), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_package(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. assert len(call.mock_calls) == 1 @@ -3994,23 +6739,21 @@ def test_delete_package_field_headers(): @pytest.mark.asyncio -async def test_delete_package_field_headers_async(): +async def test_get_version_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = 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.delete_package), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.delete_package(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. assert len(call.mock_calls) @@ -4025,18 +6768,18 @@ async def test_delete_package_field_headers_async(): ) in kw["metadata"] -def test_delete_package_flattened(): +def test_get_version_flattened(): 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: + with mock.patch.object(type(client.transport.get_version), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = version.Version() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_package( + client.get_version( name="name_value", ) @@ -4049,7 +6792,7 @@ def test_delete_package_flattened(): assert arg == mock_val -def test_delete_package_flattened_error(): +def test_get_version_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4057,29 +6800,27 @@ def test_delete_package_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_package( - package.DeletePackageRequest(), + client.get_version( + version.GetVersionRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_delete_package_flattened_async(): +async def test_get_version_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.get_version), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = version.Version() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.Version()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_package( + response = await client.get_version( name="name_value", ) @@ -4093,7 +6834,7 @@ async def test_delete_package_flattened_async(): @pytest.mark.asyncio -async def test_delete_package_flattened_error_async(): +async def test_get_version_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4101,8 +6842,8 @@ async def test_delete_package_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.delete_package( - package.DeletePackageRequest(), + await client.get_version( + version.GetVersionRequest(), name="name_value", ) @@ -4110,11 +6851,11 @@ async def test_delete_package_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - version.ListVersionsRequest, + version.DeleteVersionRequest, dict, ], ) -def test_list_versions(request_type, transport: str = "grpc"): +def test_delete_version(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -4125,24 +6866,21 @@ def test_list_versions(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_versions), "__call__") as call: + with mock.patch.object(type(client.transport.delete_version), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = version.ListVersionsResponse( - next_page_token="next_page_token_value", - ) - response = client.list_versions(request) + 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.ListVersionsRequest() + assert args[0] == version.DeleteVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, future.Future) -def test_list_versions_empty_call(): +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( @@ -4151,16 +6889,16 @@ def test_list_versions_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_versions), "__call__") as call: - client.list_versions() + with mock.patch.object(type(client.transport.delete_version), "__call__") as call: + client.delete_version() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == version.ListVersionsRequest() + assert args[0] == version.DeleteVersionRequest() @pytest.mark.asyncio -async def test_list_versions_async( - transport: str = "grpc_asyncio", request_type=version.ListVersionsRequest +async def test_delete_version_async( + transport: str = "grpc_asyncio", request_type=version.DeleteVersionRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -4172,45 +6910,42 @@ async def test_list_versions_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_versions), "__call__") as call: + with mock.patch.object(type(client.transport.delete_version), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - version.ListVersionsResponse( - next_page_token="next_page_token_value", - ) + operations_pb2.Operation(name="operations/spam") ) - response = await client.list_versions(request) + 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.ListVersionsRequest() + assert args[0] == version.DeleteVersionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsAsyncPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_list_versions_async_from_dict(): - await test_list_versions_async(request_type=dict) +async def test_delete_version_async_from_dict(): + await test_delete_version_async(request_type=dict) -def test_list_versions_field_headers(): +def test_delete_version_field_headers(): 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 = version.DeleteVersionRequest() - request.parent = "parent_value" + request.name = "name_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) + 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. assert len(call.mock_calls) == 1 @@ -4221,28 +6956,28 @@ def test_list_versions_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_list_versions_field_headers_async(): +async def test_delete_version_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = version.DeleteVersionRequest() - request.parent = "parent_value" + request.name = "name_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: + with mock.patch.object(type(client.transport.delete_version), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - version.ListVersionsResponse() + operations_pb2.Operation(name="operations/op") ) - await client.list_versions(request) + await client.delete_version(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -4253,35 +6988,35 @@ async def test_list_versions_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] -def test_list_versions_flattened(): +def test_delete_version_flattened(): 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: + with mock.patch.object(type(client.transport.delete_version), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = version.ListVersionsResponse() + 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.list_versions( - parent="parent_value", + client.delete_version( + name="name_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] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_list_versions_flattened_error(): +def test_delete_version_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4289,43 +7024,43 @@ def test_list_versions_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_versions( - version.ListVersionsRequest(), - parent="parent_value", + client.delete_version( + version.DeleteVersionRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_list_versions_flattened_async(): +async def test_delete_version_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.delete_version), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = version.ListVersionsResponse() + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - version.ListVersionsResponse() + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_versions( - parent="parent_value", + response = await client.delete_version( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_list_versions_flattened_error_async(): +async def test_delete_version_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4333,208 +7068,20 @@ async def test_list_versions_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_versions( - version.ListVersionsRequest(), - parent="parent_value", - ) - - -def test_list_versions_pager(transport_name: str = "grpc"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_versions), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - version.Version(), - ], - next_page_token="abc", - ), - version.ListVersionsResponse( - versions=[], - next_page_token="def", - ), - version.ListVersionsResponse( - versions=[ - version.Version(), - ], - next_page_token="ghi", - ), - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_versions(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, version.Version) for i in results) - - -def test_list_versions_pages(transport_name: str = "grpc"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_versions), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - version.Version(), - ], - next_page_token="abc", - ), - version.ListVersionsResponse( - versions=[], - next_page_token="def", - ), - version.ListVersionsResponse( - versions=[ - version.Version(), - ], - next_page_token="ghi", - ), - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - ], - ), - RuntimeError, - ) - pages = list(client.list_versions(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_list_versions_async_pager(): - client = ArtifactRegistryAsyncClient( - 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__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - version.Version(), - ], - next_page_token="abc", - ), - version.ListVersionsResponse( - versions=[], - next_page_token="def", - ), - version.ListVersionsResponse( - versions=[ - version.Version(), - ], - next_page_token="ghi", - ), - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_versions( - request={}, - ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, version.Version) for i in responses) - - -@pytest.mark.asyncio -async def test_list_versions_async_pages(): - client = ArtifactRegistryAsyncClient( - 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__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - version.Version(), - ], - next_page_token="abc", - ), - version.ListVersionsResponse( - versions=[], - next_page_token="def", - ), - version.ListVersionsResponse( - versions=[ - version.Version(), - ], - next_page_token="ghi", - ), - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - ], - ), - RuntimeError, + await client.delete_version( + version.DeleteVersionRequest(), + name="name_value", ) - pages = [] - async for page_ in ( - await client.list_versions(request={}) - ).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - version.GetVersionRequest, + file.ListFilesRequest, dict, ], ) -def test_get_version(request_type, transport: str = "grpc"): +def test_list_files(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -4545,26 +7092,24 @@ def test_get_version(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_version), "__call__") as call: + with mock.patch.object(type(client.transport.list_files), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = version.Version( - name="name_value", - description="description_value", + call.return_value = file.ListFilesResponse( + next_page_token="next_page_token_value", ) - response = client.get_version(request) + 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] == version.GetVersionRequest() + assert args[0] == file.ListFilesRequest() # 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" + assert isinstance(response, pagers.ListFilesPager) + assert response.next_page_token == "next_page_token_value" -def test_get_version_empty_call(): +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( @@ -4573,16 +7118,16 @@ def test_get_version_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_version), "__call__") as call: - client.get_version() + with mock.patch.object(type(client.transport.list_files), "__call__") as call: + client.list_files() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == version.GetVersionRequest() + assert args[0] == file.ListFilesRequest() @pytest.mark.asyncio -async def test_get_version_async( - transport: str = "grpc_asyncio", request_type=version.GetVersionRequest +async def test_list_files_async( + transport: str = "grpc_asyncio", request_type=file.ListFilesRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -4594,47 +7139,45 @@ async def test_get_version_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_version), "__call__") as call: + with mock.patch.object(type(client.transport.list_files), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - version.Version( - name="name_value", - description="description_value", + file.ListFilesResponse( + next_page_token="next_page_token_value", ) ) - response = await client.get_version(request) + 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] == version.GetVersionRequest() + assert args[0] == file.ListFilesRequest() # 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" + assert isinstance(response, pagers.ListFilesAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_get_version_async_from_dict(): - await test_get_version_async(request_type=dict) +async def test_list_files_async_from_dict(): + await test_list_files_async(request_type=dict) -def test_get_version_field_headers(): +def test_list_files_field_headers(): 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 = file.ListFilesRequest() - request.name = "name_value" + request.parent = "parent_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) + 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. assert len(call.mock_calls) == 1 @@ -4645,26 +7188,28 @@ def test_get_version_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_version_field_headers_async(): +async def test_list_files_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = file.ListFilesRequest() - request.name = "name_value" + request.parent = "parent_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) + with mock.patch.object(type(client.transport.list_files), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + file.ListFilesResponse() + ) + await client.list_files(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -4675,35 +7220,35 @@ async def test_get_version_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] -def test_get_version_flattened(): +def test_list_files_flattened(): 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: + with mock.patch.object(type(client.transport.list_files), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = version.Version() + call.return_value = file.ListFilesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_version( - name="name_value", + client.list_files( + parent="parent_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] - arg = args[0].name - mock_val = "name_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val -def test_get_version_flattened_error(): +def test_list_files_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4711,62 +7256,252 @@ def test_get_version_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_version( - version.GetVersionRequest(), - name="name_value", + client.list_files( + file.ListFilesRequest(), + parent="parent_value", ) @pytest.mark.asyncio -async def test_get_version_flattened_async(): +async def test_list_files_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.list_files), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = version.Version() + call.return_value = file.ListFilesResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.Version()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + file.ListFilesResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_version( - name="name_value", + response = await client.list_files( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_files_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_files( + file.ListFilesRequest(), + parent="parent_value", + ) + + +def test_list_files_pager(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_files), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + file.ListFilesResponse( + files=[ + file.File(), + file.File(), + file.File(), + ], + next_page_token="abc", + ), + file.ListFilesResponse( + files=[], + next_page_token="def", + ), + file.ListFilesResponse( + files=[ + file.File(), + ], + next_page_token="ghi", + ), + file.ListFilesResponse( + files=[ + file.File(), + file.File(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_files(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, file.File) for i in results) + + +def test_list_files_pages(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_files), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + file.ListFilesResponse( + files=[ + file.File(), + file.File(), + file.File(), + ], + next_page_token="abc", + ), + file.ListFilesResponse( + files=[], + next_page_token="def", + ), + file.ListFilesResponse( + files=[ + file.File(), + ], + next_page_token="ghi", + ), + file.ListFilesResponse( + files=[ + file.File(), + file.File(), + ], + ), + RuntimeError, + ) + pages = list(client.list_files(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_files_async_pager(): + client = ArtifactRegistryAsyncClient( + 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__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + file.ListFilesResponse( + files=[ + file.File(), + file.File(), + file.File(), + ], + next_page_token="abc", + ), + file.ListFilesResponse( + files=[], + next_page_token="def", + ), + file.ListFilesResponse( + files=[ + file.File(), + ], + next_page_token="ghi", + ), + file.ListFilesResponse( + files=[ + file.File(), + file.File(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_files( + request={}, ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val + assert len(responses) == 6 + assert all(isinstance(i, file.File) for i in responses) @pytest.mark.asyncio -async def test_get_version_flattened_error_async(): +async def test_list_files_async_pages(): client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_version( - version.GetVersionRequest(), - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_files), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + file.ListFilesResponse( + files=[ + file.File(), + file.File(), + file.File(), + ], + next_page_token="abc", + ), + file.ListFilesResponse( + files=[], + next_page_token="def", + ), + file.ListFilesResponse( + files=[ + file.File(), + ], + next_page_token="ghi", + ), + file.ListFilesResponse( + files=[ + file.File(), + file.File(), + ], + ), + RuntimeError, ) + pages = [] + async for page_ in ( + await client.list_files(request={}) + ).pages: # pragma: no branch + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - version.DeleteVersionRequest, + file.GetFileRequest, dict, ], ) -def test_delete_version(request_type, transport: str = "grpc"): +def test_get_file(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -4777,21 +7512,28 @@ def test_delete_version(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_version), "__call__") as call: + with mock.patch.object(type(client.transport.get_file), "__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) + 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] == version.DeleteVersionRequest() + assert args[0] == file.GetFileRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, file.File) + assert response.name == "name_value" + assert response.size_bytes == 1089 + assert response.owner == "owner_value" -def test_delete_version_empty_call(): +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( @@ -4800,16 +7542,16 @@ def test_delete_version_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_version), "__call__") as call: - client.delete_version() + with mock.patch.object(type(client.transport.get_file), "__call__") as call: + client.get_file() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == version.DeleteVersionRequest() + assert args[0] == file.GetFileRequest() @pytest.mark.asyncio -async def test_delete_version_async( - transport: str = "grpc_asyncio", request_type=version.DeleteVersionRequest +async def test_get_file_async( + transport: str = "grpc_asyncio", request_type=file.GetFileRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -4821,42 +7563,49 @@ async def test_delete_version_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_version), "__call__") as call: + with mock.patch.object(type(client.transport.get_file), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + file.File( + name="name_value", + size_bytes=1089, + owner="owner_value", + ) ) - response = await client.delete_version(request) + 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] == version.DeleteVersionRequest() + assert args[0] == file.GetFileRequest() # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, file.File) + assert response.name == "name_value" + assert response.size_bytes == 1089 + assert response.owner == "owner_value" @pytest.mark.asyncio -async def test_delete_version_async_from_dict(): - await test_delete_version_async(request_type=dict) +async def test_get_file_async_from_dict(): + await test_get_file_async(request_type=dict) -def test_delete_version_field_headers(): +def test_get_file_field_headers(): 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 = 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.delete_version), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_version(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. assert len(call.mock_calls) == 1 @@ -4872,23 +7621,21 @@ def test_delete_version_field_headers(): @pytest.mark.asyncio -async def test_delete_version_field_headers_async(): +async def test_get_file_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = 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.delete_version), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.delete_version(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. assert len(call.mock_calls) @@ -4903,18 +7650,18 @@ async def test_delete_version_field_headers_async(): ) in kw["metadata"] -def test_delete_version_flattened(): +def test_get_file_flattened(): 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: + with mock.patch.object(type(client.transport.get_file), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = file.File() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_version( + client.get_file( name="name_value", ) @@ -4927,7 +7674,7 @@ def test_delete_version_flattened(): assert arg == mock_val -def test_delete_version_flattened_error(): +def test_get_file_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4935,29 +7682,27 @@ def test_delete_version_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_version( - version.DeleteVersionRequest(), + client.get_file( + file.GetFileRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_delete_version_flattened_async(): +async def test_get_file_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.get_file), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = file.File() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.File()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_version( + response = await client.get_file( name="name_value", ) @@ -4971,7 +7716,7 @@ async def test_delete_version_flattened_async(): @pytest.mark.asyncio -async def test_delete_version_flattened_error_async(): +async def test_get_file_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4979,8 +7724,8 @@ async def test_delete_version_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.delete_version( - version.DeleteVersionRequest(), + await client.get_file( + file.GetFileRequest(), name="name_value", ) @@ -4988,11 +7733,11 @@ async def test_delete_version_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - file.ListFilesRequest, + tag.ListTagsRequest, dict, ], ) -def test_list_files(request_type, transport: str = "grpc"): +def test_list_tags(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -5003,24 +7748,24 @@ def test_list_files(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_files), "__call__") as call: + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse( + call.return_value = tag.ListTagsResponse( next_page_token="next_page_token_value", ) - response = client.list_files(request) + 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] == file.ListFilesRequest() + assert args[0] == tag.ListTagsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesPager) + assert isinstance(response, pagers.ListTagsPager) assert response.next_page_token == "next_page_token_value" -def test_list_files_empty_call(): +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( @@ -5029,16 +7774,16 @@ def test_list_files_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_files), "__call__") as call: - client.list_files() + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: + client.list_tags() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == file.ListFilesRequest() + assert args[0] == tag.ListTagsRequest() @pytest.mark.asyncio -async def test_list_files_async( - transport: str = "grpc_asyncio", request_type=file.ListFilesRequest +async def test_list_tags_async( + transport: str = "grpc_asyncio", request_type=tag.ListTagsRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -5050,45 +7795,45 @@ async def test_list_files_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_files), "__call__") as call: + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - file.ListFilesResponse( + tag.ListTagsResponse( next_page_token="next_page_token_value", ) ) - response = await client.list_files(request) + 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] == file.ListFilesRequest() + assert args[0] == tag.ListTagsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesAsyncPager) + assert isinstance(response, pagers.ListTagsAsyncPager) assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_list_files_async_from_dict(): - await test_list_files_async(request_type=dict) +async def test_list_tags_async_from_dict(): + await test_list_tags_async(request_type=dict) -def test_list_files_field_headers(): +def test_list_tags_field_headers(): 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 = 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_files), "__call__") as call: - call.return_value = file.ListFilesResponse() - client.list_files(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. assert len(call.mock_calls) == 1 @@ -5104,23 +7849,23 @@ def test_list_files_field_headers(): @pytest.mark.asyncio -async def test_list_files_field_headers_async(): +async def test_list_tags_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = 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_files), "__call__") as call: + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - file.ListFilesResponse() + tag.ListTagsResponse() ) - await client.list_files(request) + await client.list_tags(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -5135,18 +7880,18 @@ async def test_list_files_field_headers_async(): ) in kw["metadata"] -def test_list_files_flattened(): +def test_list_tags_flattened(): 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: + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse() + 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_files( + client.list_tags( parent="parent_value", ) @@ -5159,7 +7904,7 @@ def test_list_files_flattened(): assert arg == mock_val -def test_list_files_flattened_error(): +def test_list_tags_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5167,29 +7912,29 @@ def test_list_files_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_files( - file.ListFilesRequest(), + client.list_tags( + tag.ListTagsRequest(), parent="parent_value", ) @pytest.mark.asyncio -async def test_list_files_flattened_async(): +async def test_list_tags_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse() + call.return_value = tag.ListTagsResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - file.ListFilesResponse() + tag.ListTagsResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_files( + response = await client.list_tags( parent="parent_value", ) @@ -5203,7 +7948,7 @@ async def test_list_files_flattened_async(): @pytest.mark.asyncio -async def test_list_files_flattened_error_async(): +async def test_list_tags_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5211,44 +7956,44 @@ async def test_list_files_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_files( - file.ListFilesRequest(), + await client.list_tags( + tag.ListTagsRequest(), parent="parent_value", ) -def test_list_files_pager(transport_name: str = "grpc"): +def test_list_tags_pager(transport_name: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_files), "__call__") as call: + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( - file.ListFilesResponse( - files=[ - file.File(), - file.File(), - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), + tag.Tag(), + tag.Tag(), ], next_page_token="abc", ), - file.ListFilesResponse( - files=[], + tag.ListTagsResponse( + tags=[], next_page_token="def", ), - file.ListFilesResponse( - files=[ - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), ], next_page_token="ghi", ), - file.ListFilesResponse( - files=[ - file.File(), - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), + tag.Tag(), ], ), RuntimeError, @@ -5258,95 +8003,95 @@ def test_list_files_pager(transport_name: str = "grpc"): metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) - pager = client.list_files(request={}) + pager = client.list_tags(request={}) assert pager._metadata == metadata results = list(pager) assert len(results) == 6 - assert all(isinstance(i, file.File) for i in results) + assert all(isinstance(i, tag.Tag) for i in results) -def test_list_files_pages(transport_name: str = "grpc"): +def test_list_tags_pages(transport_name: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_files), "__call__") as call: + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( - file.ListFilesResponse( - files=[ - file.File(), - file.File(), - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), + tag.Tag(), + tag.Tag(), ], next_page_token="abc", ), - file.ListFilesResponse( - files=[], + tag.ListTagsResponse( + tags=[], next_page_token="def", ), - file.ListFilesResponse( - files=[ - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), ], next_page_token="ghi", ), - file.ListFilesResponse( - files=[ - file.File(), - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), + tag.Tag(), ], ), RuntimeError, ) - pages = list(client.list_files(request={}).pages) + pages = list(client.list_tags(request={}).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @pytest.mark.asyncio -async def test_list_files_async_pager(): +async def test_list_tags_async_pager(): client = ArtifactRegistryAsyncClient( 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__", new_callable=mock.AsyncMock + type(client.transport.list_tags), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( - file.ListFilesResponse( - files=[ - file.File(), - file.File(), - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), + tag.Tag(), + tag.Tag(), ], next_page_token="abc", ), - file.ListFilesResponse( - files=[], + tag.ListTagsResponse( + tags=[], next_page_token="def", ), - file.ListFilesResponse( - files=[ - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), ], next_page_token="ghi", ), - file.ListFilesResponse( - files=[ - file.File(), - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), + tag.Tag(), ], ), RuntimeError, ) - async_pager = await client.list_files( + async_pager = await client.list_tags( request={}, ) assert async_pager.next_page_token == "abc" @@ -5355,50 +8100,50 @@ async def test_list_files_async_pager(): responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, file.File) for i in responses) + assert all(isinstance(i, tag.Tag) for i in responses) @pytest.mark.asyncio -async def test_list_files_async_pages(): +async def test_list_tags_async_pages(): client = ArtifactRegistryAsyncClient( 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__", new_callable=mock.AsyncMock + type(client.transport.list_tags), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( - file.ListFilesResponse( - files=[ - file.File(), - file.File(), - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), + tag.Tag(), + tag.Tag(), ], next_page_token="abc", ), - file.ListFilesResponse( - files=[], + tag.ListTagsResponse( + tags=[], next_page_token="def", ), - file.ListFilesResponse( - files=[ - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), ], next_page_token="ghi", ), - file.ListFilesResponse( - files=[ - file.File(), - file.File(), + tag.ListTagsResponse( + tags=[ + tag.Tag(), + tag.Tag(), ], ), RuntimeError, ) pages = [] async for page_ in ( - await client.list_files(request={}) + await client.list_tags(request={}) ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): @@ -5408,11 +8153,11 @@ async def test_list_files_async_pages(): @pytest.mark.parametrize( "request_type", [ - file.GetFileRequest, + tag.GetTagRequest, dict, ], ) -def test_get_file(request_type, transport: str = "grpc"): +def test_get_tag(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -5423,28 +8168,26 @@ def test_get_file(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_file), "__call__") as call: + with mock.patch.object(type(client.transport.get_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = file.File( + call.return_value = tag.Tag( name="name_value", - size_bytes=1089, - owner="owner_value", + version="version_value", ) - response = client.get_file(request) + 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] == file.GetFileRequest() + assert args[0] == tag.GetTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, file.File) + assert isinstance(response, tag.Tag) assert response.name == "name_value" - assert response.size_bytes == 1089 - assert response.owner == "owner_value" + assert response.version == "version_value" -def test_get_file_empty_call(): +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( @@ -5453,16 +8196,16 @@ def test_get_file_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_file), "__call__") as call: - client.get_file() + with mock.patch.object(type(client.transport.get_tag), "__call__") as call: + client.get_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == file.GetFileRequest() + assert args[0] == tag.GetTagRequest() @pytest.mark.asyncio -async def test_get_file_async( - transport: str = "grpc_asyncio", request_type=file.GetFileRequest +async def test_get_tag_async( + transport: str = "grpc_asyncio", request_type=tag.GetTagRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -5474,49 +8217,47 @@ async def test_get_file_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_file), "__call__") as call: + with mock.patch.object(type(client.transport.get_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - file.File( + tag.Tag( name="name_value", - size_bytes=1089, - owner="owner_value", + version="version_value", ) ) - response = await client.get_file(request) + 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] == file.GetFileRequest() + assert args[0] == tag.GetTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, file.File) + assert isinstance(response, tag.Tag) assert response.name == "name_value" - assert response.size_bytes == 1089 - assert response.owner == "owner_value" + assert response.version == "version_value" @pytest.mark.asyncio -async def test_get_file_async_from_dict(): - await test_get_file_async(request_type=dict) +async def test_get_tag_async_from_dict(): + await test_get_tag_async(request_type=dict) -def test_get_file_field_headers(): +def test_get_tag_field_headers(): 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 = 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_file), "__call__") as call: - call.return_value = file.File() - client.get_file(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. assert len(call.mock_calls) == 1 @@ -5532,21 +8273,21 @@ def test_get_file_field_headers(): @pytest.mark.asyncio -async def test_get_file_field_headers_async(): +async def test_get_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = 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_file), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.File()) - await client.get_file(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. assert len(call.mock_calls) @@ -5561,18 +8302,18 @@ async def test_get_file_field_headers_async(): ) in kw["metadata"] -def test_get_file_flattened(): +def test_get_tag_flattened(): 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: + with mock.patch.object(type(client.transport.get_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = file.File() + 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_file( + client.get_tag( name="name_value", ) @@ -5585,7 +8326,7 @@ def test_get_file_flattened(): assert arg == mock_val -def test_get_file_flattened_error(): +def test_get_tag_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5593,27 +8334,27 @@ def test_get_file_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_file( - file.GetFileRequest(), + client.get_tag( + tag.GetTagRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_get_file_flattened_async(): +async def test_get_tag_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.get_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = file.File() + call.return_value = tag.Tag() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.File()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_file( + response = await client.get_tag( name="name_value", ) @@ -5627,7 +8368,7 @@ async def test_get_file_flattened_async(): @pytest.mark.asyncio -async def test_get_file_flattened_error_async(): +async def test_get_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5635,8 +8376,8 @@ async def test_get_file_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_file( - file.GetFileRequest(), + await client.get_tag( + tag.GetTagRequest(), name="name_value", ) @@ -5644,11 +8385,11 @@ async def test_get_file_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - tag.ListTagsRequest, + gda_tag.CreateTagRequest, dict, ], ) -def test_list_tags(request_type, transport: str = "grpc"): +def test_create_tag(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -5659,24 +8400,26 @@ def test_list_tags(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_tags), "__call__") as call: + with mock.patch.object(type(client.transport.create_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse( - next_page_token="next_page_token_value", + call.return_value = gda_tag.Tag( + name="name_value", + version="version_value", ) - response = client.list_tags(request) + 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] == tag.ListTagsRequest() + assert args[0] == gda_tag.CreateTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, gda_tag.Tag) + assert response.name == "name_value" + assert response.version == "version_value" -def test_list_tags_empty_call(): +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( @@ -5685,16 +8428,16 @@ def test_list_tags_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_tags), "__call__") as call: - client.list_tags() + with mock.patch.object(type(client.transport.create_tag), "__call__") as call: + client.create_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.ListTagsRequest() + assert args[0] == gda_tag.CreateTagRequest() @pytest.mark.asyncio -async def test_list_tags_async( - transport: str = "grpc_asyncio", request_type=tag.ListTagsRequest +async def test_create_tag_async( + transport: str = "grpc_asyncio", request_type=gda_tag.CreateTagRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -5706,45 +8449,47 @@ async def test_list_tags_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_tags), "__call__") as call: + with mock.patch.object(type(client.transport.create_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - tag.ListTagsResponse( - next_page_token="next_page_token_value", + gda_tag.Tag( + name="name_value", + version="version_value", ) ) - response = await client.list_tags(request) + 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] == tag.ListTagsRequest() + assert args[0] == gda_tag.CreateTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsAsyncPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, gda_tag.Tag) + assert response.name == "name_value" + assert response.version == "version_value" @pytest.mark.asyncio -async def test_list_tags_async_from_dict(): - await test_list_tags_async(request_type=dict) +async def test_create_tag_async_from_dict(): + await test_create_tag_async(request_type=dict) -def test_list_tags_field_headers(): +def test_create_tag_field_headers(): 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 = 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.list_tags), "__call__") as call: - call.return_value = tag.ListTagsResponse() - client.list_tags(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. assert len(call.mock_calls) == 1 @@ -5760,23 +8505,21 @@ def test_list_tags_field_headers(): @pytest.mark.asyncio -async def test_list_tags_field_headers_async(): +async def test_create_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = 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.list_tags), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - tag.ListTagsResponse() - ) - await client.list_tags(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. assert len(call.mock_calls) @@ -5791,19 +8534,21 @@ async def test_list_tags_field_headers_async(): ) in kw["metadata"] -def test_list_tags_flattened(): +def test_create_tag_flattened(): 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: + with mock.patch.object(type(client.transport.create_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse() + 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.list_tags( + client.create_tag( parent="parent_value", + tag=gda_tag.Tag(name="name_value"), + tag_id="tag_id_value", ) # Establish that the underlying call was made with the expected @@ -5813,9 +8558,15 @@ def test_list_tags_flattened(): arg = args[0].parent mock_val = "parent_value" assert arg == mock_val + arg = args[0].tag + mock_val = gda_tag.Tag(name="name_value") + assert arg == mock_val + arg = args[0].tag_id + mock_val = "tag_id_value" + assert arg == mock_val -def test_list_tags_flattened_error(): +def test_create_tag_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5823,252 +8574,74 @@ def test_list_tags_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_tags( - tag.ListTagsRequest(), - parent="parent_value", - ) - - -@pytest.mark.asyncio -async def test_list_tags_flattened_async(): - client = ArtifactRegistryAsyncClient( - 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.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - tag.ListTagsResponse() - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_tags( + client.create_tag( + gda_tag.CreateTagRequest(), parent="parent_value", + tag=gda_tag.Tag(name="name_value"), + tag_id="tag_id_value", ) - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - @pytest.mark.asyncio -async def test_list_tags_flattened_error_async(): +async def test_create_tag_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_tags( - tag.ListTagsRequest(), - parent="parent_value", - ) - - -def test_list_tags_pager(transport_name: str = "grpc"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_tags), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - tag.Tag(), - ], - next_page_token="abc", - ), - tag.ListTagsResponse( - tags=[], - next_page_token="def", - ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - ], - next_page_token="ghi", - ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_tags(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, tag.Tag) for i in results) - - -def test_list_tags_pages(transport_name: str = "grpc"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials, - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_tags), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - tag.Tag(), - ], - next_page_token="abc", - ), - tag.ListTagsResponse( - tags=[], - next_page_token="def", - ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - ], - next_page_token="ghi", - ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - ], - ), - RuntimeError, - ) - pages = list(client.list_tags(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_list_tags_async_pager(): - client = ArtifactRegistryAsyncClient( - 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__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - tag.Tag(), - ], - next_page_token="abc", - ), - tag.ListTagsResponse( - tags=[], - next_page_token="def", - ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - ], - next_page_token="ghi", - ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_tags( - request={}, + + # 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.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_tag( + parent="parent_value", + tag=gda_tag.Tag(name="name_value"), + tag_id="tag_id_value", ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - assert len(responses) == 6 - assert all(isinstance(i, tag.Tag) for i in responses) + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].tag + mock_val = gda_tag.Tag(name="name_value") + assert arg == mock_val + arg = args[0].tag_id + mock_val = "tag_id_value" + assert arg == mock_val @pytest.mark.asyncio -async def test_list_tags_async_pages(): +async def test_create_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials, + 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__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - tag.Tag(), - ], - next_page_token="abc", - ), - tag.ListTagsResponse( - tags=[], - next_page_token="def", - ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - ], - next_page_token="ghi", - ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - ], - ), - RuntimeError, + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_tag( + gda_tag.CreateTagRequest(), + parent="parent_value", + tag=gda_tag.Tag(name="name_value"), + tag_id="tag_id_value", ) - pages = [] - async for page_ in ( - await client.list_tags(request={}) - ).pages: # pragma: no branch - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token @pytest.mark.parametrize( "request_type", [ - tag.GetTagRequest, + gda_tag.UpdateTagRequest, dict, ], ) -def test_get_tag(request_type, transport: str = "grpc"): +def test_update_tag(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6079,26 +8652,26 @@ def test_get_tag(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_tag), "__call__") as call: + with mock.patch.object(type(client.transport.update_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.Tag( + call.return_value = gda_tag.Tag( name="name_value", version="version_value", ) - response = client.get_tag(request) + 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] == tag.GetTagRequest() + assert args[0] == gda_tag.UpdateTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) + assert isinstance(response, gda_tag.Tag) assert response.name == "name_value" assert response.version == "version_value" -def test_get_tag_empty_call(): +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( @@ -6107,16 +8680,16 @@ def test_get_tag_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_tag), "__call__") as call: - client.get_tag() + with mock.patch.object(type(client.transport.update_tag), "__call__") as call: + client.update_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.GetTagRequest() + assert args[0] == gda_tag.UpdateTagRequest() @pytest.mark.asyncio -async def test_get_tag_async( - transport: str = "grpc_asyncio", request_type=tag.GetTagRequest +async def test_update_tag_async( + transport: str = "grpc_asyncio", request_type=gda_tag.UpdateTagRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -6128,47 +8701,47 @@ async def test_get_tag_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_tag), "__call__") as call: + with mock.patch.object(type(client.transport.update_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - tag.Tag( + gda_tag.Tag( name="name_value", version="version_value", ) ) - response = await client.get_tag(request) + 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] == tag.GetTagRequest() + assert args[0] == gda_tag.UpdateTagRequest() # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) + assert isinstance(response, gda_tag.Tag) assert response.name == "name_value" assert response.version == "version_value" @pytest.mark.asyncio -async def test_get_tag_async_from_dict(): - await test_get_tag_async(request_type=dict) +async def test_update_tag_async_from_dict(): + await test_update_tag_async(request_type=dict) -def test_get_tag_field_headers(): +def test_update_tag_field_headers(): 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 = gda_tag.UpdateTagRequest() - request.name = "name_value" + request.tag.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) + 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. assert len(call.mock_calls) == 1 @@ -6179,26 +8752,26 @@ def test_get_tag_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "tag.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_tag_field_headers_async(): +async def test_update_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = gda_tag.UpdateTagRequest() - request.name = "name_value" + request.tag.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) + 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. assert len(call.mock_calls) @@ -6209,35 +8782,39 @@ async def test_get_tag_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "tag.name=name_value", ) in kw["metadata"] -def test_get_tag_flattened(): +def test_update_tag_flattened(): 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: + with mock.patch.object(type(client.transport.update_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.Tag() + 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.get_tag( - name="name_value", + client.update_tag( + tag=gda_tag.Tag(name="name_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] - arg = args[0].name - mock_val = "name_value" + arg = args[0].tag + mock_val = gda_tag.Tag(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val -def test_get_tag_flattened_error(): +def test_update_tag_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6245,41 +8822,46 @@ def test_get_tag_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_tag( - tag.GetTagRequest(), - name="name_value", + client.update_tag( + gda_tag.UpdateTagRequest(), + tag=gda_tag.Tag(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio -async def test_get_tag_flattened_async(): +async def test_update_tag_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.update_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.Tag() + call.return_value = gda_tag.Tag() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_tag( - name="name_value", + response = await client.update_tag( + tag=gda_tag.Tag(name="name_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] - arg = args[0].name - mock_val = "name_value" + arg = args[0].tag + mock_val = gda_tag.Tag(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val @pytest.mark.asyncio -async def test_get_tag_flattened_error_async(): +async def test_update_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6287,20 +8869,21 @@ async def test_get_tag_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_tag( - tag.GetTagRequest(), - name="name_value", + await client.update_tag( + gda_tag.UpdateTagRequest(), + tag=gda_tag.Tag(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.parametrize( "request_type", [ - gda_tag.CreateTagRequest, + tag.DeleteTagRequest, dict, ], ) -def test_create_tag(request_type, transport: str = "grpc"): +def test_delete_tag(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6311,26 +8894,21 @@ def test_create_tag(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_tag), "__call__") as call: + with mock.patch.object(type(client.transport.delete_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) + 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] == gda_tag.CreateTagRequest() + assert args[0] == tag.DeleteTagRequest() # 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" + assert response is None -def test_create_tag_empty_call(): +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( @@ -6339,16 +8917,16 @@ def test_create_tag_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_tag), "__call__") as call: - client.create_tag() + with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: + client.delete_tag() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.CreateTagRequest() + assert args[0] == tag.DeleteTagRequest() @pytest.mark.asyncio -async def test_create_tag_async( - transport: str = "grpc_asyncio", request_type=gda_tag.CreateTagRequest +async def test_delete_tag_async( + transport: str = "grpc_asyncio", request_type=tag.DeleteTagRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -6360,47 +8938,40 @@ async def test_create_tag_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_tag), "__call__") as call: + 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( - gda_tag.Tag( - name="name_value", - version="version_value", - ) - ) - response = await client.create_tag(request) + 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] == gda_tag.CreateTagRequest() + assert args[0] == tag.DeleteTagRequest() # 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" + assert response is None @pytest.mark.asyncio -async def test_create_tag_async_from_dict(): - await test_create_tag_async(request_type=dict) +async def test_delete_tag_async_from_dict(): + await test_delete_tag_async(request_type=dict) -def test_create_tag_field_headers(): +def test_delete_tag_field_headers(): 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 = tag.DeleteTagRequest() - request.parent = "parent_value" + request.name = "name_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) + 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. assert len(call.mock_calls) == 1 @@ -6411,26 +8982,26 @@ def test_create_tag_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_create_tag_field_headers_async(): +async def test_delete_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = tag.DeleteTagRequest() - request.parent = "parent_value" + request.name = "name_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) + 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. assert len(call.mock_calls) @@ -6441,43 +9012,35 @@ async def test_create_tag_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "name=name_value", ) in kw["metadata"] -def test_create_tag_flattened(): +def test_delete_tag_flattened(): 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: + with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag() + call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_tag( - parent="parent_value", - tag=gda_tag.Tag(name="name_value"), - tag_id="tag_id_value", + client.delete_tag( + name="name_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] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - arg = args[0].tag - mock_val = gda_tag.Tag(name="name_value") - assert arg == mock_val - arg = args[0].tag_id - mock_val = "tag_id_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_create_tag_flattened_error(): +def test_delete_tag_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6485,51 +9048,41 @@ def test_create_tag_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_tag( - gda_tag.CreateTagRequest(), - parent="parent_value", - tag=gda_tag.Tag(name="name_value"), - tag_id="tag_id_value", + client.delete_tag( + tag.DeleteTagRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_create_tag_flattened_async(): +async def test_delete_tag_flattened_async(): client = ArtifactRegistryAsyncClient( 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: + with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag() + call.return_value = None - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_tag( - parent="parent_value", - tag=gda_tag.Tag(name="name_value"), - tag_id="tag_id_value", + response = await client.delete_tag( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" - assert arg == mock_val - arg = args[0].tag - mock_val = gda_tag.Tag(name="name_value") - assert arg == mock_val - arg = args[0].tag_id - mock_val = "tag_id_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_create_tag_flattened_error_async(): +async def test_delete_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6537,22 +9090,20 @@ async def test_create_tag_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.create_tag( - gda_tag.CreateTagRequest(), - parent="parent_value", - tag=gda_tag.Tag(name="name_value"), - tag_id="tag_id_value", + await client.delete_tag( + tag.DeleteTagRequest(), + name="name_value", ) @pytest.mark.parametrize( "request_type", [ - gda_tag.UpdateTagRequest, + iam_policy_pb2.SetIamPolicyRequest, dict, ], ) -def test_update_tag(request_type, transport: str = "grpc"): +def test_set_iam_policy(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6563,26 +9114,26 @@ def test_update_tag(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_tag), "__call__") as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag( - name="name_value", - version="version_value", + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", ) - response = client.update_tag(request) + 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] == gda_tag.UpdateTagRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() # 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" + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" -def test_update_tag_empty_call(): +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( @@ -6591,16 +9142,16 @@ def test_update_tag_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_tag), "__call__") as call: - client.update_tag() + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: + client.set_iam_policy() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.UpdateTagRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() @pytest.mark.asyncio -async def test_update_tag_async( - transport: str = "grpc_asyncio", request_type=gda_tag.UpdateTagRequest +async def test_set_iam_policy_async( + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -6612,47 +9163,47 @@ async def test_update_tag_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_tag), "__call__") as call: + 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( - gda_tag.Tag( - name="name_value", - version="version_value", + policy_pb2.Policy( + version=774, + etag=b"etag_blob", ) ) - response = await client.update_tag(request) + 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] == gda_tag.UpdateTagRequest() + assert args[0] == iam_policy_pb2.SetIamPolicyRequest() # 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" + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" @pytest.mark.asyncio -async def test_update_tag_async_from_dict(): - await test_update_tag_async(request_type=dict) +async def test_set_iam_policy_async_from_dict(): + await test_set_iam_policy_async(request_type=dict) -def test_update_tag_field_headers(): +def test_set_iam_policy_field_headers(): 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 = iam_policy_pb2.SetIamPolicyRequest() - request.tag.name = "name_value" + request.resource = "resource_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) + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: + call.return_value = policy_pb2.Policy() + client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -6663,26 +9214,26 @@ def test_update_tag_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "tag.name=name_value", + "resource=resource_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_tag_field_headers_async(): +async def test_set_iam_policy_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = iam_policy_pb2.SetIamPolicyRequest() - request.tag.name = "name_value" + request.resource = "resource_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) + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: + 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. assert len(call.mock_calls) @@ -6691,110 +9242,38 @@ async def test_update_tag_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "tag.name=name_value", - ) in kw["metadata"] - - -def test_update_tag_flattened(): - 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_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] - arg = args[0].tag - mock_val = gda_tag.Tag(name="name_value") - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) - assert arg == mock_val - - -def test_update_tag_flattened_error(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_tag( - gda_tag.UpdateTagRequest(), - tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - - -@pytest.mark.asyncio -async def test_update_tag_flattened_async(): - client = ArtifactRegistryAsyncClient( - 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.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_tag( - tag=gda_tag.Tag(name="name_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] - arg = args[0].tag - mock_val = gda_tag.Tag(name="name_value") - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) - assert arg == mock_val + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] -@pytest.mark.asyncio -async def test_update_tag_flattened_error_async(): - client = ArtifactRegistryAsyncClient( +def test_set_iam_policy_from_dict_foreign(): + client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_tag( - gda_tag.UpdateTagRequest(), - tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_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: + # Designate an appropriate return value for the call. + call.return_value = policy_pb2.Policy() + response = client.set_iam_policy( + request={ + "resource": "resource_value", + "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), + } ) + call.assert_called() @pytest.mark.parametrize( "request_type", [ - tag.DeleteTagRequest, + iam_policy_pb2.GetIamPolicyRequest, dict, ], ) -def test_delete_tag(request_type, transport: str = "grpc"): +def test_get_iam_policy(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6805,21 +9284,26 @@ def test_delete_tag(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_tag(request) + 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] == tag.DeleteTagRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" -def test_delete_tag_empty_call(): +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( @@ -6828,16 +9312,16 @@ def test_delete_tag_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: - client.delete_tag() + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: + client.get_iam_policy() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.DeleteTagRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() @pytest.mark.asyncio -async def test_delete_tag_async( - transport: str = "grpc_asyncio", request_type=tag.DeleteTagRequest +async def test_get_iam_policy_async( + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -6849,40 +9333,47 @@ async def test_delete_tag_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: + 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(None) - response = await client.delete_tag(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + 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] == tag.DeleteTagRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest() # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" @pytest.mark.asyncio -async def test_delete_tag_async_from_dict(): - await test_delete_tag_async(request_type=dict) +async def test_get_iam_policy_async_from_dict(): + await test_get_iam_policy_async(request_type=dict) -def test_delete_tag_field_headers(): +def test_get_iam_policy_field_headers(): 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 = iam_policy_pb2.GetIamPolicyRequest() - request.name = "name_value" + request.resource = "resource_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) + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: + call.return_value = policy_pb2.Policy() + client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -6893,26 +9384,26 @@ def test_delete_tag_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "resource=resource_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_delete_tag_field_headers_async(): +async def test_get_iam_policy_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = iam_policy_pb2.GetIamPolicyRequest() - request.name = "name_value" + request.resource = "resource_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) + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: + 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. assert len(call.mock_calls) @@ -6923,98 +9414,35 @@ async def test_delete_tag_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "resource=resource_value", ) in kw["metadata"] -def test_delete_tag_flattened(): - 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", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -def test_delete_tag_flattened_error(): +def test_get_iam_policy_from_dict_foreign(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_tag( - tag.DeleteTagRequest(), - name="name_value", - ) - - -@pytest.mark.asyncio -async def test_delete_tag_flattened_async(): - client = ArtifactRegistryAsyncClient( - 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: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = None - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_tag( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_delete_tag_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_tag( - tag.DeleteTagRequest(), - name="name_value", + call.return_value = policy_pb2.Policy() + response = client.get_iam_policy( + request={ + "resource": "resource_value", + "options": options_pb2.GetPolicyOptions(requested_policy_version=2598), + } ) + call.assert_called() @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.SetIamPolicyRequest, + iam_policy_pb2.TestIamPermissionsRequest, dict, ], ) -def test_set_iam_policy(request_type, transport: str = "grpc"): +def test_test_iam_permissions(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7025,26 +9453,26 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): request = request_type() # 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: + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", + call.return_value = iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], ) - response = client.set_iam_policy(request) + 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_pb2.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert response.permissions == ["permissions_value"] -def test_set_iam_policy_empty_call(): +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( @@ -7053,16 +9481,19 @@ def test_set_iam_policy_empty_call(): ) # 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: - client.set_iam_policy() + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: + client.test_iam_permissions() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() @pytest.mark.asyncio -async def test_set_iam_policy_async( - transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest +async def test_test_iam_permissions_async( + transport: str = "grpc_asyncio", + request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -7074,47 +9505,49 @@ async def test_set_iam_policy_async( request = request_type() # 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: + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy( - version=774, - etag=b"etag_blob", + iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], ) ) - response = await client.set_iam_policy(request) + 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_pb2.SetIamPolicyRequest() + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert response.permissions == ["permissions_value"] @pytest.mark.asyncio -async def test_set_iam_policy_async_from_dict(): - await test_set_iam_policy_async(request_type=dict) +async def test_test_iam_permissions_async_from_dict(): + await test_test_iam_permissions_async(request_type=dict) -def test_set_iam_policy_field_headers(): +def test_test_iam_permissions_field_headers(): 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_pb2.SetIamPolicyRequest() + 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.set_iam_policy), "__call__") as call: - call.return_value = policy_pb2.Policy() - client.set_iam_policy(request) + # 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_pb2.TestIamPermissionsResponse() + client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7130,21 +9563,25 @@ def test_set_iam_policy_field_headers(): @pytest.mark.asyncio -async def test_set_iam_policy_field_headers_async(): +async def test_test_iam_permissions_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.SetIamPolicyRequest() + request = 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.set_iam_policy), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) - await client.set_iam_policy(request) + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + iam_policy_pb2.TestIamPermissionsResponse() + ) + await client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7159,19 +9596,20 @@ async def test_set_iam_policy_field_headers_async(): ) in kw["metadata"] -def test_set_iam_policy_from_dict_foreign(): +def test_test_iam_permissions_from_dict_foreign(): 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: + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy() - response = client.set_iam_policy( + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + response = client.test_iam_permissions( request={ "resource": "resource_value", - "policy": policy_pb2.Policy(version=774), - "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), + "permissions": ["permissions_value"], } ) call.assert_called() @@ -7180,11 +9618,11 @@ def test_set_iam_policy_from_dict_foreign(): @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.GetIamPolicyRequest, + settings.GetProjectSettingsRequest, dict, ], ) -def test_get_iam_policy(request_type, transport: str = "grpc"): +def test_get_project_settings(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7195,26 +9633,31 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): request = request_type() # 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: + with mock.patch.object( + type(client.transport.get_project_settings), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", + call.return_value = settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, ) - response = client.get_iam_policy(request) + response = client.get_project_settings(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_pb2.GetIamPolicyRequest() + assert args[0] == settings.GetProjectSettingsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, settings.ProjectSettings) + assert response.name == "name_value" + assert ( + response.legacy_redirection_state + == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED + ) -def test_get_iam_policy_empty_call(): +def test_get_project_settings_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( @@ -7223,16 +9666,18 @@ def test_get_iam_policy_empty_call(): ) # 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: - client.get_iam_policy() + with mock.patch.object( + type(client.transport.get_project_settings), "__call__" + ) as call: + client.get_project_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.GetIamPolicyRequest() + assert args[0] == settings.GetProjectSettingsRequest() @pytest.mark.asyncio -async def test_get_iam_policy_async( - transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest +async def test_get_project_settings_async( + transport: str = "grpc_asyncio", request_type=settings.GetProjectSettingsRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -7244,47 +9689,54 @@ async def test_get_iam_policy_async( request = request_type() # 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: + with mock.patch.object( + type(client.transport.get_project_settings), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy( - version=774, - etag=b"etag_blob", + settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, ) ) - response = await client.get_iam_policy(request) + response = await client.get_project_settings(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_pb2.GetIamPolicyRequest() + assert args[0] == settings.GetProjectSettingsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, settings.ProjectSettings) + assert response.name == "name_value" + assert ( + response.legacy_redirection_state + == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED + ) @pytest.mark.asyncio -async def test_get_iam_policy_async_from_dict(): - await test_get_iam_policy_async(request_type=dict) +async def test_get_project_settings_async_from_dict(): + await test_get_project_settings_async(request_type=dict) -def test_get_iam_policy_field_headers(): +def test_get_project_settings_field_headers(): 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_pb2.GetIamPolicyRequest() + request = settings.GetProjectSettingsRequest() - request.resource = "resource_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: - call.return_value = policy_pb2.Policy() - client.get_iam_policy(request) + with mock.patch.object( + type(client.transport.get_project_settings), "__call__" + ) as call: + call.return_value = settings.ProjectSettings() + client.get_project_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7295,26 +9747,30 @@ def test_get_iam_policy_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_iam_policy_field_headers_async(): +async def test_get_project_settings_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.GetIamPolicyRequest() + request = settings.GetProjectSettingsRequest() - request.resource = "resource_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) - await client.get_iam_policy(request) + with mock.patch.object( + type(client.transport.get_project_settings), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + settings.ProjectSettings() + ) + await client.get_project_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7325,35 +9781,104 @@ async def test_get_iam_policy_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "name=name_value", ) in kw["metadata"] -def test_get_iam_policy_from_dict_foreign(): +def test_get_project_settings_flattened(): 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: + with mock.patch.object( + type(client.transport.get_project_settings), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy() - response = client.get_iam_policy( - request={ - "resource": "resource_value", - "options": options_pb2.GetPolicyOptions(requested_policy_version=2598), - } + call.return_value = settings.ProjectSettings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_project_settings( + name="name_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] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_project_settings_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_project_settings( + settings.GetProjectSettingsRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_project_settings_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_project_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = settings.ProjectSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + settings.ProjectSettings() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_project_settings( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_project_settings_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_project_settings( + settings.GetProjectSettingsRequest(), + name="name_value", ) - call.assert_called() @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.TestIamPermissionsRequest, + settings.UpdateProjectSettingsRequest, dict, ], ) -def test_test_iam_permissions(request_type, transport: str = "grpc"): +def test_update_project_settings(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7365,25 +9890,30 @@ def test_test_iam_permissions(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" + type(client.transport.update_project_settings), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], + call.return_value = settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, ) - response = client.test_iam_permissions(request) + response = client.update_project_settings(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_pb2.TestIamPermissionsRequest() + assert args[0] == settings.UpdateProjectSettingsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ["permissions_value"] + assert isinstance(response, settings.ProjectSettings) + assert response.name == "name_value" + assert ( + response.legacy_redirection_state + == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED + ) -def test_test_iam_permissions_empty_call(): +def test_update_project_settings_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( @@ -7393,18 +9923,17 @@ def test_test_iam_permissions_empty_call(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" + type(client.transport.update_project_settings), "__call__" ) as call: - client.test_iam_permissions() + client.update_project_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.TestIamPermissionsRequest() + assert args[0] == settings.UpdateProjectSettingsRequest() @pytest.mark.asyncio -async def test_test_iam_permissions_async( - transport: str = "grpc_asyncio", - request_type=iam_policy_pb2.TestIamPermissionsRequest, +async def test_update_project_settings_async( + transport: str = "grpc_asyncio", request_type=settings.UpdateProjectSettingsRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -7417,48 +9946,53 @@ async def test_test_iam_permissions_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" + type(client.transport.update_project_settings), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], + settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, ) ) - response = await client.test_iam_permissions(request) + response = await client.update_project_settings(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_pb2.TestIamPermissionsRequest() + assert args[0] == settings.UpdateProjectSettingsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ["permissions_value"] + assert isinstance(response, settings.ProjectSettings) + assert response.name == "name_value" + assert ( + response.legacy_redirection_state + == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED + ) @pytest.mark.asyncio -async def test_test_iam_permissions_async_from_dict(): - await test_test_iam_permissions_async(request_type=dict) +async def test_update_project_settings_async_from_dict(): + await test_update_project_settings_async(request_type=dict) -def test_test_iam_permissions_field_headers(): +def test_update_project_settings_field_headers(): 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_pb2.TestIamPermissionsRequest() + request = settings.UpdateProjectSettingsRequest() - request.resource = "resource_value" + request.project_settings.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" + type(client.transport.update_project_settings), "__call__" ) as call: - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() - client.test_iam_permissions(request) + call.return_value = settings.ProjectSettings() + client.update_project_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7469,30 +10003,30 @@ def test_test_iam_permissions_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "project_settings.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_test_iam_permissions_field_headers_async(): +async def test_update_project_settings_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.TestIamPermissionsRequest() + request = settings.UpdateProjectSettingsRequest() - request.resource = "resource_value" + request.project_settings.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" + type(client.transport.update_project_settings), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy_pb2.TestIamPermissionsResponse() + settings.ProjectSettings() ) - await client.test_iam_permissions(request) + await client.update_project_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7503,37 +10037,114 @@ async def test_test_iam_permissions_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "project_settings.name=name_value", ) in kw["metadata"] -def test_test_iam_permissions_from_dict_foreign(): +def test_update_project_settings_flattened(): 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__" + type(client.transport.update_project_settings), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() - response = client.test_iam_permissions( - request={ - "resource": "resource_value", - "permissions": ["permissions_value"], - } + call.return_value = settings.ProjectSettings() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_project_settings( + project_settings=settings.ProjectSettings(name="name_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] + arg = args[0].project_settings + mock_val = settings.ProjectSettings(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_project_settings_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_project_settings( + settings.UpdateProjectSettingsRequest(), + project_settings=settings.ProjectSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_project_settings_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_project_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = settings.ProjectSettings() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + settings.ProjectSettings() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_project_settings( + project_settings=settings.ProjectSettings(name="name_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] + arg = args[0].project_settings + mock_val = settings.ProjectSettings(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_project_settings_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_project_settings( + settings.UpdateProjectSettingsRequest(), + project_settings=settings.ProjectSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - call.assert_called() @pytest.mark.parametrize( "request_type", [ - settings.GetProjectSettingsRequest, + vpcsc_config.GetVPCSCConfigRequest, dict, ], ) -def test_get_project_settings(request_type, transport: str = "grpc"): +def test_get_vpcsc_config(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7544,31 +10155,26 @@ def test_get_project_settings(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_project_settings), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings( + call.return_value = vpcsc_config.VPCSCConfig( name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, ) - response = client.get_project_settings(request) + response = client.get_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == settings.GetProjectSettingsRequest() + assert args[0] == vpcsc_config.GetVPCSCConfigRequest() # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) + assert isinstance(response, vpcsc_config.VPCSCConfig) assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY -def test_get_project_settings_empty_call(): +def test_get_vpcsc_config_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( @@ -7577,18 +10183,16 @@ def test_get_project_settings_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_project_settings), "__call__" - ) as call: - client.get_project_settings() + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + client.get_vpcsc_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == settings.GetProjectSettingsRequest() + assert args[0] == vpcsc_config.GetVPCSCConfigRequest() @pytest.mark.asyncio -async def test_get_project_settings_async( - transport: str = "grpc_asyncio", request_type=settings.GetProjectSettingsRequest +async def test_get_vpcsc_config_async( + transport: str = "grpc_asyncio", request_type=vpcsc_config.GetVPCSCConfigRequest ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -7600,54 +10204,47 @@ async def test_get_project_settings_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_project_settings), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings( + vpcsc_config.VPCSCConfig( name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, ) ) - response = await client.get_project_settings(request) + response = await client.get_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == settings.GetProjectSettingsRequest() + assert args[0] == vpcsc_config.GetVPCSCConfigRequest() # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) + assert isinstance(response, vpcsc_config.VPCSCConfig) assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY @pytest.mark.asyncio -async def test_get_project_settings_async_from_dict(): - await test_get_project_settings_async(request_type=dict) +async def test_get_vpcsc_config_async_from_dict(): + await test_get_vpcsc_config_async(request_type=dict) -def test_get_project_settings_field_headers(): +def test_get_vpcsc_config_field_headers(): 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 = settings.GetProjectSettingsRequest() + request = vpcsc_config.GetVPCSCConfigRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_project_settings), "__call__" - ) as call: - call.return_value = settings.ProjectSettings() - client.get_project_settings(request) + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + call.return_value = vpcsc_config.VPCSCConfig() + client.get_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7663,25 +10260,23 @@ def test_get_project_settings_field_headers(): @pytest.mark.asyncio -async def test_get_project_settings_field_headers_async(): +async def test_get_vpcsc_config_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = settings.GetProjectSettingsRequest() + request = vpcsc_config.GetVPCSCConfigRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_project_settings), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings() + vpcsc_config.VPCSCConfig() ) - await client.get_project_settings(request) + await client.get_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7696,20 +10291,18 @@ async def test_get_project_settings_field_headers_async(): ) in kw["metadata"] -def test_get_project_settings_flattened(): +def test_get_vpcsc_config_flattened(): 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_project_settings), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings() + call.return_value = vpcsc_config.VPCSCConfig() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_project_settings( + client.get_vpcsc_config( name="name_value", ) @@ -7722,7 +10315,7 @@ def test_get_project_settings_flattened(): assert arg == mock_val -def test_get_project_settings_flattened_error(): +def test_get_vpcsc_config_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -7730,31 +10323,29 @@ def test_get_project_settings_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_project_settings( - settings.GetProjectSettingsRequest(), + client.get_vpcsc_config( + vpcsc_config.GetVPCSCConfigRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_get_project_settings_flattened_async(): +async def test_get_vpcsc_config_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_project_settings), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings() + call.return_value = vpcsc_config.VPCSCConfig() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings() + vpcsc_config.VPCSCConfig() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_project_settings( + response = await client.get_vpcsc_config( name="name_value", ) @@ -7768,7 +10359,7 @@ async def test_get_project_settings_flattened_async(): @pytest.mark.asyncio -async def test_get_project_settings_flattened_error_async(): +async def test_get_vpcsc_config_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -7776,8 +10367,8 @@ async def test_get_project_settings_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_project_settings( - settings.GetProjectSettingsRequest(), + await client.get_vpcsc_config( + vpcsc_config.GetVPCSCConfigRequest(), name="name_value", ) @@ -7785,11 +10376,11 @@ async def test_get_project_settings_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - settings.UpdateProjectSettingsRequest, + gda_vpcsc_config.UpdateVPCSCConfigRequest, dict, ], ) -def test_update_project_settings(request_type, transport: str = "grpc"): +def test_update_vpcsc_config(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7801,30 +10392,27 @@ def test_update_project_settings(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_project_settings), "__call__" + type(client.transport.update_vpcsc_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings( + call.return_value = gda_vpcsc_config.VPCSCConfig( name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, ) - response = client.update_project_settings(request) + response = client.update_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == settings.UpdateProjectSettingsRequest() + assert args[0] == gda_vpcsc_config.UpdateVPCSCConfigRequest() # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) + assert isinstance(response, gda_vpcsc_config.VPCSCConfig) assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY -def test_update_project_settings_empty_call(): +def test_update_vpcsc_config_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( @@ -7834,17 +10422,18 @@ def test_update_project_settings_empty_call(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_project_settings), "__call__" + type(client.transport.update_vpcsc_config), "__call__" ) as call: - client.update_project_settings() + client.update_vpcsc_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == settings.UpdateProjectSettingsRequest() + assert args[0] == gda_vpcsc_config.UpdateVPCSCConfigRequest() @pytest.mark.asyncio -async def test_update_project_settings_async( - transport: str = "grpc_asyncio", request_type=settings.UpdateProjectSettingsRequest +async def test_update_vpcsc_config_async( + transport: str = "grpc_asyncio", + request_type=gda_vpcsc_config.UpdateVPCSCConfigRequest, ): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), @@ -7857,53 +10446,50 @@ async def test_update_project_settings_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_project_settings), "__call__" + type(client.transport.update_vpcsc_config), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings( + gda_vpcsc_config.VPCSCConfig( name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, ) ) - response = await client.update_project_settings(request) + response = await client.update_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == settings.UpdateProjectSettingsRequest() + assert args[0] == gda_vpcsc_config.UpdateVPCSCConfigRequest() # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) + assert isinstance(response, gda_vpcsc_config.VPCSCConfig) assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY @pytest.mark.asyncio -async def test_update_project_settings_async_from_dict(): - await test_update_project_settings_async(request_type=dict) +async def test_update_vpcsc_config_async_from_dict(): + await test_update_vpcsc_config_async(request_type=dict) -def test_update_project_settings_field_headers(): +def test_update_vpcsc_config_field_headers(): 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 = settings.UpdateProjectSettingsRequest() + request = gda_vpcsc_config.UpdateVPCSCConfigRequest() - request.project_settings.name = "name_value" + request.vpcsc_config.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_project_settings), "__call__" + type(client.transport.update_vpcsc_config), "__call__" ) as call: - call.return_value = settings.ProjectSettings() - client.update_project_settings(request) + call.return_value = gda_vpcsc_config.VPCSCConfig() + client.update_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7914,30 +10500,30 @@ def test_update_project_settings_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "project_settings.name=name_value", + "vpcsc_config.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_project_settings_field_headers_async(): +async def test_update_vpcsc_config_field_headers_async(): client = ArtifactRegistryAsyncClient( 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 = settings.UpdateProjectSettingsRequest() + request = gda_vpcsc_config.UpdateVPCSCConfigRequest() - request.project_settings.name = "name_value" + request.vpcsc_config.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_project_settings), "__call__" + type(client.transport.update_vpcsc_config), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings() + gda_vpcsc_config.VPCSCConfig() ) - await client.update_project_settings(request) + await client.update_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7948,25 +10534,25 @@ async def test_update_project_settings_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "project_settings.name=name_value", + "vpcsc_config.name=name_value", ) in kw["metadata"] -def test_update_project_settings_flattened(): +def test_update_vpcsc_config_flattened(): 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_project_settings), "__call__" + type(client.transport.update_vpcsc_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings() + call.return_value = gda_vpcsc_config.VPCSCConfig() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_project_settings( - project_settings=settings.ProjectSettings(name="name_value"), + client.update_vpcsc_config( + vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -7974,15 +10560,15 @@ def test_update_project_settings_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].project_settings - mock_val = settings.ProjectSettings(name="name_value") + arg = args[0].vpcsc_config + mock_val = gda_vpcsc_config.VPCSCConfig(name="name_value") assert arg == mock_val arg = args[0].update_mask mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val -def test_update_project_settings_flattened_error(): +def test_update_vpcsc_config_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -7990,33 +10576,33 @@ def test_update_project_settings_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_project_settings( - settings.UpdateProjectSettingsRequest(), - project_settings=settings.ProjectSettings(name="name_value"), + client.update_vpcsc_config( + gda_vpcsc_config.UpdateVPCSCConfigRequest(), + vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio -async def test_update_project_settings_flattened_async(): +async def test_update_vpcsc_config_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_project_settings), "__call__" + type(client.transport.update_vpcsc_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings() + call.return_value = gda_vpcsc_config.VPCSCConfig() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings() + gda_vpcsc_config.VPCSCConfig() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.update_project_settings( - project_settings=settings.ProjectSettings(name="name_value"), + response = await client.update_vpcsc_config( + vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -8024,8 +10610,8 @@ async def test_update_project_settings_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].project_settings - mock_val = settings.ProjectSettings(name="name_value") + arg = args[0].vpcsc_config + mock_val = gda_vpcsc_config.VPCSCConfig(name="name_value") assert arg == mock_val arg = args[0].update_mask mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) @@ -8033,7 +10619,7 @@ async def test_update_project_settings_flattened_async(): @pytest.mark.asyncio -async def test_update_project_settings_flattened_error_async(): +async def test_update_vpcsc_config_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -8041,9 +10627,9 @@ async def test_update_project_settings_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.update_project_settings( - settings.UpdateProjectSettingsRequest(), - project_settings=settings.ProjectSettings(name="name_value"), + await client.update_vpcsc_config( + gda_vpcsc_config.UpdateVPCSCConfigRequest(), + vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -8187,6 +10773,12 @@ def test_artifact_registry_base_transport(): methods = ( "list_docker_images", "get_docker_image", + "list_maven_artifacts", + "get_maven_artifact", + "list_npm_packages", + "get_npm_package", + "list_python_packages", + "get_python_package", "import_apt_artifacts", "import_yum_artifacts", "list_repositories", @@ -8212,8 +10804,11 @@ def test_artifact_registry_base_transport(): "test_iam_permissions", "get_project_settings", "update_project_settings", + "get_vpcsc_config", + "update_vpcsc_config", "get_location", "list_locations", + "get_operation", ) for method in methods: with pytest.raises(NotImplementedError): @@ -8701,6 +11296,97 @@ def test_parse_file_path(): assert expected == actual +def test_maven_artifact_path(): + project = "squid" + location = "clam" + repository = "whelk" + maven_artifact = "octopus" + expected = "projects/{project}/locations/{location}/repositories/{repository}/mavenArtifacts/{maven_artifact}".format( + project=project, + location=location, + repository=repository, + maven_artifact=maven_artifact, + ) + actual = ArtifactRegistryClient.maven_artifact_path( + project, location, repository, maven_artifact + ) + assert expected == actual + + +def test_parse_maven_artifact_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "repository": "cuttlefish", + "maven_artifact": "mussel", + } + path = ArtifactRegistryClient.maven_artifact_path(**expected) + + # Check that the path construction is reversible. + actual = ArtifactRegistryClient.parse_maven_artifact_path(path) + assert expected == actual + + +def test_npm_package_path(): + project = "winkle" + location = "nautilus" + repository = "scallop" + npm_package = "abalone" + expected = "projects/{project}/locations/{location}/repositories/{repository}/npmPackages/{npm_package}".format( + project=project, + location=location, + repository=repository, + npm_package=npm_package, + ) + actual = ArtifactRegistryClient.npm_package_path( + project, location, repository, npm_package + ) + assert expected == actual + + +def test_parse_npm_package_path(): + expected = { + "project": "squid", + "location": "clam", + "repository": "whelk", + "npm_package": "octopus", + } + path = ArtifactRegistryClient.npm_package_path(**expected) + + # Check that the path construction is reversible. + actual = ArtifactRegistryClient.parse_npm_package_path(path) + assert expected == actual + + +def test_package_path(): + project = "oyster" + location = "nudibranch" + repository = "cuttlefish" + package = "mussel" + expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}".format( + project=project, + location=location, + repository=repository, + package=package, + ) + actual = ArtifactRegistryClient.package_path(project, location, repository, package) + assert expected == actual + + +def test_parse_package_path(): + expected = { + "project": "winkle", + "location": "nautilus", + "repository": "scallop", + "package": "abalone", + } + path = ArtifactRegistryClient.package_path(**expected) + + # Check that the path construction is reversible. + actual = ArtifactRegistryClient.parse_package_path(path) + assert expected == actual + + def test_project_settings_path(): project = "squid" expected = "projects/{project}/projectSettings".format( @@ -8721,10 +11407,41 @@ def test_parse_project_settings_path(): assert expected == actual -def test_repository_path(): +def test_python_package_path(): project = "whelk" location = "octopus" repository = "oyster" + python_package = "nudibranch" + expected = "projects/{project}/locations/{location}/repositories/{repository}/pythonPackages/{python_package}".format( + project=project, + location=location, + repository=repository, + python_package=python_package, + ) + actual = ArtifactRegistryClient.python_package_path( + project, location, repository, python_package + ) + assert expected == actual + + +def test_parse_python_package_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + "repository": "winkle", + "python_package": "nautilus", + } + path = ArtifactRegistryClient.python_package_path(**expected) + + # Check that the path construction is reversible. + actual = ArtifactRegistryClient.parse_python_package_path(path) + assert expected == actual + + +def test_repository_path(): + project = "scallop" + location = "abalone" + repository = "squid" expected = ( "projects/{project}/locations/{location}/repositories/{repository}".format( project=project, @@ -8738,9 +11455,9 @@ def test_repository_path(): def test_parse_repository_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "repository": "mussel", + "project": "clam", + "location": "whelk", + "repository": "octopus", } path = ArtifactRegistryClient.repository_path(**expected) @@ -8750,11 +11467,11 @@ def test_parse_repository_path(): def test_tag_path(): - project = "winkle" - location = "nautilus" - repository = "scallop" - package = "abalone" - tag = "squid" + project = "oyster" + location = "nudibranch" + repository = "cuttlefish" + package = "mussel" + tag = "winkle" expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag}".format( project=project, location=location, @@ -8770,11 +11487,11 @@ def test_tag_path(): def test_parse_tag_path(): expected = { - "project": "clam", - "location": "whelk", - "repository": "octopus", - "package": "oyster", - "tag": "nudibranch", + "project": "nautilus", + "location": "scallop", + "repository": "abalone", + "package": "squid", + "tag": "clam", } path = ArtifactRegistryClient.tag_path(**expected) @@ -8784,11 +11501,11 @@ def test_parse_tag_path(): def test_version_path(): - project = "cuttlefish" - location = "mussel" - repository = "winkle" - package = "nautilus" - version = "scallop" + project = "whelk" + location = "octopus" + repository = "oyster" + package = "nudibranch" + version = "cuttlefish" expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/versions/{version}".format( project=project, location=location, @@ -8804,11 +11521,11 @@ def test_version_path(): def test_parse_version_path(): expected = { - "project": "abalone", - "location": "squid", - "repository": "clam", - "package": "whelk", - "version": "octopus", + "project": "mussel", + "location": "winkle", + "repository": "nautilus", + "package": "scallop", + "version": "abalone", } path = ArtifactRegistryClient.version_path(**expected) @@ -8817,6 +11534,29 @@ def test_parse_version_path(): assert expected == actual +def test_vpcsc_config_path(): + project = "squid" + location = "clam" + expected = "projects/{project}/locations/{location}/vpcscConfig".format( + project=project, + location=location, + ) + actual = ArtifactRegistryClient.vpcsc_config_path(project, location) + assert expected == actual + + +def test_parse_vpcsc_config_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = ArtifactRegistryClient.vpcsc_config_path(**expected) + + # Check that the path construction is reversible. + actual = ArtifactRegistryClient.parse_vpcsc_config_path(path) + assert expected == actual + + def test_yum_artifact_path(): project = "oyster" location = "nudibranch" @@ -8988,6 +11728,151 @@ async def test_transport_close_async(): close.assert_called_once() +def test_get_operation(transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +@pytest.mark.asyncio +async def test_get_operation_async(transport: str = "grpc"): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_get_operation_field_headers(): + 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 = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = ArtifactRegistryAsyncClient( + 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 = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=locations", + ) in kw["metadata"] + + +def test_get_operation_from_dict(): + 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_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = ArtifactRegistryAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + def test_list_locations(transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(),