From c37eea50447a074d607da8ddaa67352cbc959328 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 25 Oct 2024 23:59:48 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20post-p?= =?UTF-8?q?rocessor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../v1/.coveragerc | 13 - .../google-cloud-artifact-registry/v1/.flake8 | 33 - .../v1/MANIFEST.in | 2 - .../v1/README.rst | 49 - .../v1/docs/_static/custom.css | 3 - .../artifactregistry_v1/artifact_registry.rst | 10 - .../v1/docs/artifactregistry_v1/services_.rst | 6 - .../v1/docs/artifactregistry_v1/types_.rst | 6 - .../v1/docs/conf.py | 376 - .../v1/docs/index.rst | 7 - .../google/cloud/artifactregistry/__init__.py | 209 - .../cloud/artifactregistry/gapic_version.py | 16 - .../v1/google/cloud/artifactregistry/py.typed | 2 - .../cloud/artifactregistry_v1/__init__.py | 210 - .../artifactregistry_v1/gapic_metadata.json | 763 - .../artifactregistry_v1/gapic_version.py | 16 - .../google/cloud/artifactregistry_v1/py.typed | 2 - .../artifactregistry_v1/services/__init__.py | 15 - .../services/artifact_registry/__init__.py | 22 - .../artifact_registry/async_client.py | 5983 --- .../services/artifact_registry/client.py | 6429 --- .../services/artifact_registry/pagers.py | 1519 - .../artifact_registry/transports/README.rst | 9 - .../artifact_registry/transports/__init__.py | 38 - .../artifact_registry/transports/base.py | 897 - .../artifact_registry/transports/grpc.py | 1652 - .../transports/grpc_asyncio.py | 1928 - .../artifact_registry/transports/rest.py | 5874 --- .../artifact_registry/transports/rest_base.py | 2053 - .../artifactregistry_v1/types/__init__.py | 228 - .../artifactregistry_v1/types/apt_artifact.py | 210 - .../artifactregistry_v1/types/artifact.py | 595 - .../cloud/artifactregistry_v1/types/file.py | 320 - .../artifactregistry_v1/types/package.py | 255 - .../artifactregistry_v1/types/repository.py | 1437 - .../artifactregistry_v1/types/service.py | 36 - .../artifactregistry_v1/types/settings.py | 134 - .../cloud/artifactregistry_v1/types/tag.py | 238 - .../artifactregistry_v1/types/version.py | 368 - .../artifactregistry_v1/types/vpcsc_config.py | 122 - .../artifactregistry_v1/types/yum_artifact.py | 194 - .../v1/mypy.ini | 3 - .../v1/noxfile.py | 280 - ...ct_registry_batch_delete_versions_async.py | 56 - ...act_registry_batch_delete_versions_sync.py | 56 - ...tifact_registry_create_repository_async.py | 57 - ...rtifact_registry_create_repository_sync.py | 57 - ...ated_artifact_registry_create_tag_async.py | 51 - ...rated_artifact_registry_create_tag_sync.py | 51 - ..._artifact_registry_delete_package_async.py | 56 - ...d_artifact_registry_delete_package_sync.py | 56 - ...tifact_registry_delete_repository_async.py | 56 - ...rtifact_registry_delete_repository_sync.py | 56 - ...ated_artifact_registry_delete_tag_async.py | 49 - ...rated_artifact_registry_delete_tag_sync.py | 49 - ..._artifact_registry_delete_version_async.py | 55 - ...d_artifact_registry_delete_version_sync.py | 55 - ...rtifact_registry_get_docker_image_async.py | 52 - ...artifact_registry_get_docker_image_sync.py | 52 - ...erated_artifact_registry_get_file_async.py | 52 - ...nerated_artifact_registry_get_file_sync.py | 52 - ..._artifact_registry_get_iam_policy_async.py | 53 - ...d_artifact_registry_get_iam_policy_sync.py | 53 - ...ifact_registry_get_maven_artifact_async.py | 52 - ...tifact_registry_get_maven_artifact_sync.py | 52 - ...artifact_registry_get_npm_package_async.py | 52 - ..._artifact_registry_get_npm_package_sync.py | 52 - ...ted_artifact_registry_get_package_async.py | 52 - ...ated_artifact_registry_get_package_sync.py | 52 - ...act_registry_get_project_settings_async.py | 52 - ...fact_registry_get_project_settings_sync.py | 52 - ...ifact_registry_get_python_package_async.py | 52 - ...tifact_registry_get_python_package_sync.py | 52 - ..._artifact_registry_get_repository_async.py | 52 - ...d_artifact_registry_get_repository_sync.py | 52 - ...nerated_artifact_registry_get_tag_async.py | 51 - ...enerated_artifact_registry_get_tag_sync.py | 51 - ...ted_artifact_registry_get_version_async.py | 51 - ...ated_artifact_registry_get_version_sync.py | 51 - ...rtifact_registry_get_vpcsc_config_async.py | 52 - ...artifact_registry_get_vpcsc_config_sync.py | 52 - ...act_registry_import_apt_artifacts_async.py | 55 - ...fact_registry_import_apt_artifacts_sync.py | 55 - ...act_registry_import_yum_artifacts_async.py | 55 - ...fact_registry_import_yum_artifacts_sync.py | 55 - ...ifact_registry_list_docker_images_async.py | 53 - ...tifact_registry_list_docker_images_sync.py | 53 - ...ated_artifact_registry_list_files_async.py | 53 - ...rated_artifact_registry_list_files_sync.py | 53 - ...act_registry_list_maven_artifacts_async.py | 53 - ...fact_registry_list_maven_artifacts_sync.py | 53 - ...tifact_registry_list_npm_packages_async.py | 53 - ...rtifact_registry_list_npm_packages_sync.py | 53 - ...d_artifact_registry_list_packages_async.py | 53 - ...ed_artifact_registry_list_packages_sync.py | 53 - ...act_registry_list_python_packages_async.py | 53 - ...fact_registry_list_python_packages_sync.py | 53 - ...tifact_registry_list_repositories_async.py | 53 - ...rtifact_registry_list_repositories_sync.py | 53 - ...rated_artifact_registry_list_tags_async.py | 52 - ...erated_artifact_registry_list_tags_sync.py | 52 - ...d_artifact_registry_list_versions_async.py | 52 - ...ed_artifact_registry_list_versions_sync.py | 52 - ..._artifact_registry_set_iam_policy_async.py | 53 - ...d_artifact_registry_set_iam_policy_sync.py | 53 - ...act_registry_test_iam_permissions_async.py | 54 - ...fact_registry_test_iam_permissions_sync.py | 54 - ..._registry_update_project_settings_async.py | 51 - ...t_registry_update_project_settings_sync.py | 51 - ...tifact_registry_update_repository_async.py | 51 - ...rtifact_registry_update_repository_sync.py | 51 - ...ated_artifact_registry_update_tag_async.py | 51 - ...rated_artifact_registry_update_tag_sync.py | 51 - ...fact_registry_update_vpcsc_config_async.py | 51 - ...ifact_registry_update_vpcsc_config_sync.py | 51 - ...a_google.devtools.artifactregistry.v1.json | 7988 ---- .../fixup_artifactregistry_v1_keywords.py | 224 - .../v1/setup.py | 99 - .../v1/testing/constraints-3.10.txt | 7 - .../v1/testing/constraints-3.11.txt | 7 - .../v1/testing/constraints-3.12.txt | 7 - .../v1/testing/constraints-3.13.txt | 7 - .../v1/testing/constraints-3.7.txt | 11 - .../v1/testing/constraints-3.8.txt | 7 - .../v1/testing/constraints-3.9.txt | 7 - .../v1/tests/__init__.py | 16 - .../v1/tests/unit/__init__.py | 16 - .../v1/tests/unit/gapic/__init__.py | 16 - .../gapic/artifactregistry_v1/__init__.py | 16 - .../test_artifact_registry.py | 36796 ---------------- .../v1beta2/.coveragerc | 13 - .../v1beta2/.flake8 | 33 - .../v1beta2/MANIFEST.in | 2 - .../v1beta2/README.rst | 49 - .../v1beta2/docs/_static/custom.css | 3 - .../artifact_registry.rst | 10 - .../artifactregistry_v1beta2/services_.rst | 6 - .../docs/artifactregistry_v1beta2/types_.rst | 6 - .../v1beta2/docs/conf.py | 376 - .../v1beta2/docs/index.rst | 7 - .../google/cloud/artifactregistry/__init__.py | 119 - .../cloud/artifactregistry/gapic_version.py | 16 - .../google/cloud/artifactregistry/py.typed | 2 - .../artifactregistry_v1beta2/__init__.py | 120 - .../gapic_metadata.json | 403 - .../artifactregistry_v1beta2/gapic_version.py | 16 - .../cloud/artifactregistry_v1beta2/py.typed | 2 - .../services/__init__.py | 15 - .../services/artifact_registry/__init__.py | 22 - .../artifact_registry/async_client.py | 3139 -- .../services/artifact_registry/client.py | 3528 -- .../services/artifact_registry/pagers.py | 706 - .../artifact_registry/transports/README.rst | 9 - .../artifact_registry/transports/__init__.py | 38 - .../artifact_registry/transports/base.py | 672 - .../artifact_registry/transports/grpc.py | 992 - .../transports/grpc_asyncio.py | 1278 - .../artifact_registry/transports/rest.py | 3207 -- .../artifact_registry/transports/rest_base.py | 1034 - .../types/__init__.py | 128 - .../types/apt_artifact.py | 210 - .../artifactregistry_v1beta2/types/file.py | 213 - .../artifactregistry_v1beta2/types/package.py | 159 - .../types/repository.py | 331 - .../artifactregistry_v1beta2/types/service.py | 36 - .../types/settings.py | 119 - .../artifactregistry_v1beta2/types/tag.py | 220 - .../artifactregistry_v1beta2/types/version.py | 234 - .../types/yum_artifact.py | 194 - .../v1beta2/mypy.ini | 3 - .../v1beta2/noxfile.py | 280 - ...tifact_registry_create_repository_async.py | 56 - ...rtifact_registry_create_repository_sync.py | 56 - ...ated_artifact_registry_create_tag_async.py | 51 - ...rated_artifact_registry_create_tag_sync.py | 51 - ..._artifact_registry_delete_package_async.py | 55 - ...d_artifact_registry_delete_package_sync.py | 55 - ...tifact_registry_delete_repository_async.py | 56 - ...rtifact_registry_delete_repository_sync.py | 56 - ...ated_artifact_registry_delete_tag_async.py | 49 - ...rated_artifact_registry_delete_tag_sync.py | 49 - ..._artifact_registry_delete_version_async.py | 55 - ...d_artifact_registry_delete_version_sync.py | 55 - ...erated_artifact_registry_get_file_async.py | 51 - ...nerated_artifact_registry_get_file_sync.py | 51 - ..._artifact_registry_get_iam_policy_async.py | 53 - ...d_artifact_registry_get_iam_policy_sync.py | 53 - ...ted_artifact_registry_get_package_async.py | 51 - ...ated_artifact_registry_get_package_sync.py | 51 - ...act_registry_get_project_settings_async.py | 52 - ...fact_registry_get_project_settings_sync.py | 52 - ..._artifact_registry_get_repository_async.py | 52 - ...d_artifact_registry_get_repository_sync.py | 52 - ...nerated_artifact_registry_get_tag_async.py | 51 - ...enerated_artifact_registry_get_tag_sync.py | 51 - ...ted_artifact_registry_get_version_async.py | 51 - ...ated_artifact_registry_get_version_sync.py | 51 - ...act_registry_import_apt_artifacts_async.py | 55 - ...fact_registry_import_apt_artifacts_sync.py | 55 - ...act_registry_import_yum_artifacts_async.py | 55 - ...fact_registry_import_yum_artifacts_sync.py | 55 - ...ated_artifact_registry_list_files_async.py | 52 - ...rated_artifact_registry_list_files_sync.py | 52 - ...d_artifact_registry_list_packages_async.py | 52 - ...ed_artifact_registry_list_packages_sync.py | 52 - ...tifact_registry_list_repositories_async.py | 53 - ...rtifact_registry_list_repositories_sync.py | 53 - ...rated_artifact_registry_list_tags_async.py | 52 - ...erated_artifact_registry_list_tags_sync.py | 52 - ...d_artifact_registry_list_versions_async.py | 52 - ...ed_artifact_registry_list_versions_sync.py | 52 - ..._artifact_registry_set_iam_policy_async.py | 53 - ...d_artifact_registry_set_iam_policy_sync.py | 53 - ...act_registry_test_iam_permissions_async.py | 54 - ...fact_registry_test_iam_permissions_sync.py | 54 - ..._registry_update_project_settings_async.py | 51 - ...t_registry_update_project_settings_sync.py | 51 - ...tifact_registry_update_repository_async.py | 51 - ...rtifact_registry_update_repository_sync.py | 51 - ...ated_artifact_registry_update_tag_async.py | 51 - ...rated_artifact_registry_update_tag_sync.py | 51 - ...gle.devtools.artifactregistry.v1beta2.json | 4050 -- ...fixup_artifactregistry_v1beta2_keywords.py | 200 - .../v1beta2/setup.py | 99 - .../v1beta2/testing/constraints-3.10.txt | 7 - .../v1beta2/testing/constraints-3.11.txt | 7 - .../v1beta2/testing/constraints-3.12.txt | 7 - .../v1beta2/testing/constraints-3.13.txt | 7 - .../v1beta2/testing/constraints-3.7.txt | 11 - .../v1beta2/testing/constraints-3.8.txt | 7 - .../v1beta2/testing/constraints-3.9.txt | 7 - .../v1beta2/tests/__init__.py | 16 - .../v1beta2/tests/unit/__init__.py | 16 - .../v1beta2/tests/unit/gapic/__init__.py | 16 - .../artifactregistry_v1beta2/__init__.py | 16 - .../test_artifact_registry.py | 18176 -------- .../google/cloud/artifactregistry/__init__.py | 40 + .../cloud/artifactregistry/gapic_version.py | 2 +- .../cloud/artifactregistry_v1/__init__.py | 48 +- .../artifactregistry_v1/gapic_metadata.json | 195 + .../artifactregistry_v1/gapic_version.py | 2 +- .../artifact_registry/async_client.py | 2226 +- .../services/artifact_registry/client.py | 2183 +- .../services/artifact_registry/pagers.py | 306 + .../artifact_registry/transports/base.py | 189 +- .../artifact_registry/transports/grpc.py | 345 +- .../transports/grpc_asyncio.py | 425 +- .../artifact_registry/transports/rest.py | 1820 +- .../artifact_registry/transports/rest_base.py | 686 +- .../artifactregistry_v1/types/__init__.py | 48 +- .../artifactregistry_v1/types/artifact.py | 4 + .../artifactregistry_v1/types/attachment.py | 26 +- .../cloud/artifactregistry_v1/types/file.py | 110 +- .../artifactregistry_v1/types/generic.py | 8 +- .../artifactregistry_v1/types/package.py | 94 + .../artifactregistry_v1/types/repository.py | 370 + .../cloud/artifactregistry_v1/types/rule.py | 33 +- .../artifactregistry_v1/types/settings.py | 15 + .../cloud/artifactregistry_v1/types/tag.py | 37 +- .../artifactregistry_v1/types/version.py | 95 +- .../artifactregistry_v1beta2/gapic_version.py | 2 +- ...tifact_registry_create_attachment_async.py | 0 ...rtifact_registry_create_attachment_sync.py | 0 ...ted_artifact_registry_create_rule_async.py | 0 ...ated_artifact_registry_create_rule_sync.py | 0 ...tifact_registry_delete_attachment_async.py | 0 ...rtifact_registry_delete_attachment_sync.py | 0 ...ted_artifact_registry_delete_file_async.py | 0 ...ated_artifact_registry_delete_file_sync.py | 0 ...ted_artifact_registry_delete_rule_async.py | 0 ...ated_artifact_registry_delete_rule_sync.py | 0 ..._artifact_registry_get_attachment_async.py | 0 ...d_artifact_registry_get_attachment_sync.py | 0 ...erated_artifact_registry_get_rule_async.py | 0 ...nerated_artifact_registry_get_rule_sync.py | 0 ...rtifact_registry_list_attachments_async.py | 0 ...artifact_registry_list_attachments_sync.py | 0 ...ated_artifact_registry_list_rules_async.py | 0 ...rated_artifact_registry_list_rules_sync.py | 0 ...ted_artifact_registry_update_file_async.py | 0 ...ated_artifact_registry_update_file_sync.py | 0 ..._artifact_registry_update_package_async.py | 0 ...d_artifact_registry_update_package_sync.py | 0 ...ted_artifact_registry_update_rule_async.py | 0 ...ated_artifact_registry_update_rule_sync.py | 0 ..._artifact_registry_update_version_async.py | 0 ...d_artifact_registry_update_version_sync.py | 0 ...a_google.devtools.artifactregistry.v1.json | 4391 +- ...gle.devtools.artifactregistry.v1beta2.json | 2 +- .../fixup_artifactregistry_v1_keywords.py | 19 +- .../test_artifact_registry.py | 24654 ++++++++--- 291 files changed, 29280 insertions(+), 133899 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/.coveragerc delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/.flake8 delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/MANIFEST.in delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/README.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/docs/_static/custom.css delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/artifact_registry.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/services_.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/types_.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/docs/conf.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/docs/index.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/py.typed delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/py.typed delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/client.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/README.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest_base.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/apt_artifact.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/artifact.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/file.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/package.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/repository.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/service.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/settings.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/tag.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/version.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/vpcsc_config.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/yum_artifact.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/mypy.ini delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/noxfile.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_batch_delete_versions_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_batch_delete_versions_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_repository_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_repository_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_tag_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_tag_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_package_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_package_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_repository_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_tag_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_version_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_version_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_package_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_package_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_repository_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_repository_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_tag_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_tag_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_version_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_version_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_packages_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_packages_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_repositories_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_repositories_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_tags_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_tags_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_versions_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_versions_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_project_settings_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_repository_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_repository_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_tag_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_tag_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/scripts/fixup_artifactregistry_v1_keywords.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/setup.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.13.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/tests/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/artifactregistry_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/.coveragerc delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/.flake8 delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/MANIFEST.in delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/README.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/_static/custom.css delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/artifact_registry.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/services_.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/types_.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/conf.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/index.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/py.typed delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/py.typed delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/README.rst delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/base.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest_base.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/apt_artifact.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/file.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/package.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/repository.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/service.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/settings.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/tag.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/version.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/yum_artifact.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/mypy.ini delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/noxfile.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_repository_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_repository_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_tag_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_tag_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_package_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_package_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_repository_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_repository_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_tag_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_tag_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_version_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_version_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_file_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_file_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_package_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_package_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_repository_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_repository_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_tag_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_tag_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_version_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_version_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_apt_artifacts_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_apt_artifacts_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_yum_artifacts_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_yum_artifacts_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_files_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_files_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_packages_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_packages_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_repositories_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_repositories_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_tags_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_tags_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_versions_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_versions_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_repository_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_repository_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_tag_async.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_tag_sync.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/scripts/fixup_artifactregistry_v1beta2_keywords.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/setup.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.13.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/artifactregistry_v1beta2/__init__.py delete mode 100644 owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/google/cloud/artifactregistry_v1/types/attachment.py (94%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/google/cloud/artifactregistry_v1/types/generic.py (96%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/google/cloud/artifactregistry_v1/types/rule.py (93%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_sync.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_async.py (100%) rename {owl-bot-staging/google-cloud-artifact-registry/v1 => packages/google-cloud-artifact-registry}/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_sync.py (100%) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/.coveragerc b/owl-bot-staging/google-cloud-artifact-registry/v1/.coveragerc deleted file mode 100644 index 5fe8843f3d6f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -[report] -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 - # Ignore debug-only repr - def __repr__ diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/.flake8 b/owl-bot-staging/google-cloud-artifact-registry/v1/.flake8 deleted file mode 100644 index 29227d4cf419..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/.flake8 +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://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 by synthtool. DO NOT EDIT! -[flake8] -ignore = E203, E266, E501, W503 -exclude = - # Exclude generated code. - **/proto/** - **/gapic/** - **/services/** - **/types/** - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/MANIFEST.in b/owl-bot-staging/google-cloud-artifact-registry/v1/MANIFEST.in deleted file mode 100644 index fbacfc69d107..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/artifactregistry *.py -recursive-include google/cloud/artifactregistry_v1 *.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/README.rst b/owl-bot-staging/google-cloud-artifact-registry/v1/README.rst deleted file mode 100644 index 2a03378bed7f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Artifactregistry API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Artifactregistry API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-artifact-registry/v1/docs/_static/custom.css deleted file mode 100644 index 06423be0b592..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/_static/custom.css +++ /dev/null @@ -1,3 +0,0 @@ -dl.field-list > dt { - min-width: 100px -} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/artifact_registry.rst b/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/artifact_registry.rst deleted file mode 100644 index 17cceae7862b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/artifact_registry.rst +++ /dev/null @@ -1,10 +0,0 @@ -ArtifactRegistry ----------------------------------- - -.. automodule:: google.cloud.artifactregistry_v1.services.artifact_registry - :members: - :inherited-members: - -.. automodule:: google.cloud.artifactregistry_v1.services.artifact_registry.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/services_.rst b/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/services_.rst deleted file mode 100644 index 9193e13593c4..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/services_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Artifactregistry v1 API -================================================= -.. toctree:: - :maxdepth: 2 - - artifact_registry diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/types_.rst b/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/types_.rst deleted file mode 100644 index 2f0411af81ef..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/artifactregistry_v1/types_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Types for Google Cloud Artifactregistry v1 API -============================================== - -.. automodule:: google.cloud.artifactregistry_v1.types - :members: - :show-inheritance: diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/conf.py b/owl-bot-staging/google-cloud-artifact-registry/v1/docs/conf.py deleted file mode 100644 index 68e126a263bf..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -# -# google-cloud-artifact-registry documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "4.0.1" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The root toctree document. -root_doc = "index" - -# General information about the project. -project = u"google-cloud-artifact-registry" -copyright = u"2023, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = 'en' - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-artifact-registry-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - root_doc, - "google-cloud-artifact-registry.tex", - u"google-cloud-artifact-registry Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - root_doc, - "google-cloud-artifact-registry", - u"Google Cloud Artifactregistry Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - root_doc, - "google-cloud-artifact-registry", - u"google-cloud-artifact-registry Documentation", - author, - "google-cloud-artifact-registry", - "GAPIC library for Google Cloud Artifactregistry API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/index.rst b/owl-bot-staging/google-cloud-artifact-registry/v1/docs/index.rst deleted file mode 100644 index ab208fd82d5e..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - artifactregistry_v1/services_ - artifactregistry_v1/types_ diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/__init__.py deleted file mode 100644 index a66b308c72fa..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/__init__.py +++ /dev/null @@ -1,209 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 google.cloud.artifactregistry import gapic_version as package_version - -__version__ = package_version.__version__ - - -from google.cloud.artifactregistry_v1.services.artifact_registry.client import ArtifactRegistryClient -from google.cloud.artifactregistry_v1.services.artifact_registry.async_client import ArtifactRegistryAsyncClient - -from google.cloud.artifactregistry_v1.types.apt_artifact import AptArtifact -from google.cloud.artifactregistry_v1.types.apt_artifact import ImportAptArtifactsErrorInfo -from google.cloud.artifactregistry_v1.types.apt_artifact import ImportAptArtifactsGcsSource -from google.cloud.artifactregistry_v1.types.apt_artifact import ImportAptArtifactsMetadata -from google.cloud.artifactregistry_v1.types.apt_artifact import ImportAptArtifactsRequest -from google.cloud.artifactregistry_v1.types.apt_artifact import ImportAptArtifactsResponse -from google.cloud.artifactregistry_v1.types.artifact import DockerImage -from google.cloud.artifactregistry_v1.types.artifact import GetDockerImageRequest -from google.cloud.artifactregistry_v1.types.artifact import GetMavenArtifactRequest -from google.cloud.artifactregistry_v1.types.artifact import GetNpmPackageRequest -from google.cloud.artifactregistry_v1.types.artifact import GetPythonPackageRequest -from google.cloud.artifactregistry_v1.types.artifact import ListDockerImagesRequest -from google.cloud.artifactregistry_v1.types.artifact import ListDockerImagesResponse -from google.cloud.artifactregistry_v1.types.artifact import ListMavenArtifactsRequest -from google.cloud.artifactregistry_v1.types.artifact import ListMavenArtifactsResponse -from google.cloud.artifactregistry_v1.types.artifact import ListNpmPackagesRequest -from google.cloud.artifactregistry_v1.types.artifact import ListNpmPackagesResponse -from google.cloud.artifactregistry_v1.types.artifact import ListPythonPackagesRequest -from google.cloud.artifactregistry_v1.types.artifact import ListPythonPackagesResponse -from google.cloud.artifactregistry_v1.types.artifact import MavenArtifact -from google.cloud.artifactregistry_v1.types.artifact import NpmPackage -from google.cloud.artifactregistry_v1.types.artifact import PythonPackage -from google.cloud.artifactregistry_v1.types.attachment import Attachment -from google.cloud.artifactregistry_v1.types.attachment import CreateAttachmentRequest -from google.cloud.artifactregistry_v1.types.attachment import DeleteAttachmentRequest -from google.cloud.artifactregistry_v1.types.attachment import GetAttachmentRequest -from google.cloud.artifactregistry_v1.types.attachment import ListAttachmentsRequest -from google.cloud.artifactregistry_v1.types.attachment import ListAttachmentsResponse -from google.cloud.artifactregistry_v1.types.file import DeleteFileRequest -from google.cloud.artifactregistry_v1.types.file import File -from google.cloud.artifactregistry_v1.types.file import GetFileRequest -from google.cloud.artifactregistry_v1.types.file import Hash -from google.cloud.artifactregistry_v1.types.file import ListFilesRequest -from google.cloud.artifactregistry_v1.types.file import ListFilesResponse -from google.cloud.artifactregistry_v1.types.file import UpdateFileRequest -from google.cloud.artifactregistry_v1.types.generic import GenericArtifact -from google.cloud.artifactregistry_v1.types.package import DeletePackageRequest -from google.cloud.artifactregistry_v1.types.package import GetPackageRequest -from google.cloud.artifactregistry_v1.types.package import ListPackagesRequest -from google.cloud.artifactregistry_v1.types.package import ListPackagesResponse -from google.cloud.artifactregistry_v1.types.package import Package -from google.cloud.artifactregistry_v1.types.package import UpdatePackageRequest -from google.cloud.artifactregistry_v1.types.repository import CleanupPolicy -from google.cloud.artifactregistry_v1.types.repository import CleanupPolicyCondition -from google.cloud.artifactregistry_v1.types.repository import CleanupPolicyMostRecentVersions -from google.cloud.artifactregistry_v1.types.repository import CreateRepositoryRequest -from google.cloud.artifactregistry_v1.types.repository import DeleteRepositoryRequest -from google.cloud.artifactregistry_v1.types.repository import GetRepositoryRequest -from google.cloud.artifactregistry_v1.types.repository import ListRepositoriesRequest -from google.cloud.artifactregistry_v1.types.repository import ListRepositoriesResponse -from google.cloud.artifactregistry_v1.types.repository import RemoteRepositoryConfig -from google.cloud.artifactregistry_v1.types.repository import Repository -from google.cloud.artifactregistry_v1.types.repository import UpdateRepositoryRequest -from google.cloud.artifactregistry_v1.types.repository import UpstreamPolicy -from google.cloud.artifactregistry_v1.types.repository import VirtualRepositoryConfig -from google.cloud.artifactregistry_v1.types.rule import CreateRuleRequest -from google.cloud.artifactregistry_v1.types.rule import DeleteRuleRequest -from google.cloud.artifactregistry_v1.types.rule import GetRuleRequest -from google.cloud.artifactregistry_v1.types.rule import ListRulesRequest -from google.cloud.artifactregistry_v1.types.rule import ListRulesResponse -from google.cloud.artifactregistry_v1.types.rule import Rule -from google.cloud.artifactregistry_v1.types.rule import UpdateRuleRequest -from google.cloud.artifactregistry_v1.types.service import OperationMetadata -from google.cloud.artifactregistry_v1.types.settings import GetProjectSettingsRequest -from google.cloud.artifactregistry_v1.types.settings import ProjectSettings -from google.cloud.artifactregistry_v1.types.settings import UpdateProjectSettingsRequest -from google.cloud.artifactregistry_v1.types.tag import CreateTagRequest -from google.cloud.artifactregistry_v1.types.tag import DeleteTagRequest -from google.cloud.artifactregistry_v1.types.tag import GetTagRequest -from google.cloud.artifactregistry_v1.types.tag import ListTagsRequest -from google.cloud.artifactregistry_v1.types.tag import ListTagsResponse -from google.cloud.artifactregistry_v1.types.tag import Tag -from google.cloud.artifactregistry_v1.types.tag import UpdateTagRequest -from google.cloud.artifactregistry_v1.types.version import BatchDeleteVersionsMetadata -from google.cloud.artifactregistry_v1.types.version import BatchDeleteVersionsRequest -from google.cloud.artifactregistry_v1.types.version import DeleteVersionRequest -from google.cloud.artifactregistry_v1.types.version import GetVersionRequest -from google.cloud.artifactregistry_v1.types.version import ListVersionsRequest -from google.cloud.artifactregistry_v1.types.version import ListVersionsResponse -from google.cloud.artifactregistry_v1.types.version import UpdateVersionRequest -from google.cloud.artifactregistry_v1.types.version import Version -from google.cloud.artifactregistry_v1.types.version import VersionView -from google.cloud.artifactregistry_v1.types.vpcsc_config import GetVPCSCConfigRequest -from google.cloud.artifactregistry_v1.types.vpcsc_config import UpdateVPCSCConfigRequest -from google.cloud.artifactregistry_v1.types.vpcsc_config import VPCSCConfig -from google.cloud.artifactregistry_v1.types.yum_artifact import ImportYumArtifactsErrorInfo -from google.cloud.artifactregistry_v1.types.yum_artifact import ImportYumArtifactsGcsSource -from google.cloud.artifactregistry_v1.types.yum_artifact import ImportYumArtifactsMetadata -from google.cloud.artifactregistry_v1.types.yum_artifact import ImportYumArtifactsRequest -from google.cloud.artifactregistry_v1.types.yum_artifact import ImportYumArtifactsResponse -from google.cloud.artifactregistry_v1.types.yum_artifact import YumArtifact - -__all__ = ('ArtifactRegistryClient', - 'ArtifactRegistryAsyncClient', - 'AptArtifact', - 'ImportAptArtifactsErrorInfo', - 'ImportAptArtifactsGcsSource', - 'ImportAptArtifactsMetadata', - 'ImportAptArtifactsRequest', - 'ImportAptArtifactsResponse', - 'DockerImage', - 'GetDockerImageRequest', - 'GetMavenArtifactRequest', - 'GetNpmPackageRequest', - 'GetPythonPackageRequest', - 'ListDockerImagesRequest', - 'ListDockerImagesResponse', - 'ListMavenArtifactsRequest', - 'ListMavenArtifactsResponse', - 'ListNpmPackagesRequest', - 'ListNpmPackagesResponse', - 'ListPythonPackagesRequest', - 'ListPythonPackagesResponse', - 'MavenArtifact', - 'NpmPackage', - 'PythonPackage', - 'Attachment', - 'CreateAttachmentRequest', - 'DeleteAttachmentRequest', - 'GetAttachmentRequest', - 'ListAttachmentsRequest', - 'ListAttachmentsResponse', - 'DeleteFileRequest', - 'File', - 'GetFileRequest', - 'Hash', - 'ListFilesRequest', - 'ListFilesResponse', - 'UpdateFileRequest', - 'GenericArtifact', - 'DeletePackageRequest', - 'GetPackageRequest', - 'ListPackagesRequest', - 'ListPackagesResponse', - 'Package', - 'UpdatePackageRequest', - 'CleanupPolicy', - 'CleanupPolicyCondition', - 'CleanupPolicyMostRecentVersions', - 'CreateRepositoryRequest', - 'DeleteRepositoryRequest', - 'GetRepositoryRequest', - 'ListRepositoriesRequest', - 'ListRepositoriesResponse', - 'RemoteRepositoryConfig', - 'Repository', - 'UpdateRepositoryRequest', - 'UpstreamPolicy', - 'VirtualRepositoryConfig', - 'CreateRuleRequest', - 'DeleteRuleRequest', - 'GetRuleRequest', - 'ListRulesRequest', - 'ListRulesResponse', - 'Rule', - 'UpdateRuleRequest', - 'OperationMetadata', - 'GetProjectSettingsRequest', - 'ProjectSettings', - 'UpdateProjectSettingsRequest', - 'CreateTagRequest', - 'DeleteTagRequest', - 'GetTagRequest', - 'ListTagsRequest', - 'ListTagsResponse', - 'Tag', - 'UpdateTagRequest', - 'BatchDeleteVersionsMetadata', - 'BatchDeleteVersionsRequest', - 'DeleteVersionRequest', - 'GetVersionRequest', - 'ListVersionsRequest', - 'ListVersionsResponse', - 'UpdateVersionRequest', - 'Version', - 'VersionView', - 'GetVPCSCConfigRequest', - 'UpdateVPCSCConfigRequest', - 'VPCSCConfig', - 'ImportYumArtifactsErrorInfo', - 'ImportYumArtifactsGcsSource', - 'ImportYumArtifactsMetadata', - 'ImportYumArtifactsRequest', - 'ImportYumArtifactsResponse', - 'YumArtifact', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/gapic_version.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/gapic_version.py deleted file mode 100644 index 558c8aab67c5..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/py.typed b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/py.typed deleted file mode 100644 index 7ee239890682..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-artifact-registry package uses inline types. diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/__init__.py deleted file mode 100644 index 31ab80bed9fc..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/__init__.py +++ /dev/null @@ -1,210 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 google.cloud.artifactregistry_v1 import gapic_version as package_version - -__version__ = package_version.__version__ - - -from .services.artifact_registry import ArtifactRegistryClient -from .services.artifact_registry import ArtifactRegistryAsyncClient - -from .types.apt_artifact import AptArtifact -from .types.apt_artifact import ImportAptArtifactsErrorInfo -from .types.apt_artifact import ImportAptArtifactsGcsSource -from .types.apt_artifact import ImportAptArtifactsMetadata -from .types.apt_artifact import ImportAptArtifactsRequest -from .types.apt_artifact import ImportAptArtifactsResponse -from .types.artifact import DockerImage -from .types.artifact import GetDockerImageRequest -from .types.artifact import GetMavenArtifactRequest -from .types.artifact import GetNpmPackageRequest -from .types.artifact import GetPythonPackageRequest -from .types.artifact import ListDockerImagesRequest -from .types.artifact import ListDockerImagesResponse -from .types.artifact import ListMavenArtifactsRequest -from .types.artifact import ListMavenArtifactsResponse -from .types.artifact import ListNpmPackagesRequest -from .types.artifact import ListNpmPackagesResponse -from .types.artifact import ListPythonPackagesRequest -from .types.artifact import ListPythonPackagesResponse -from .types.artifact import MavenArtifact -from .types.artifact import NpmPackage -from .types.artifact import PythonPackage -from .types.attachment import Attachment -from .types.attachment import CreateAttachmentRequest -from .types.attachment import DeleteAttachmentRequest -from .types.attachment import GetAttachmentRequest -from .types.attachment import ListAttachmentsRequest -from .types.attachment import ListAttachmentsResponse -from .types.file import DeleteFileRequest -from .types.file import File -from .types.file import GetFileRequest -from .types.file import Hash -from .types.file import ListFilesRequest -from .types.file import ListFilesResponse -from .types.file import UpdateFileRequest -from .types.generic import GenericArtifact -from .types.package import DeletePackageRequest -from .types.package import GetPackageRequest -from .types.package import ListPackagesRequest -from .types.package import ListPackagesResponse -from .types.package import Package -from .types.package import UpdatePackageRequest -from .types.repository import CleanupPolicy -from .types.repository import CleanupPolicyCondition -from .types.repository import CleanupPolicyMostRecentVersions -from .types.repository import CreateRepositoryRequest -from .types.repository import DeleteRepositoryRequest -from .types.repository import GetRepositoryRequest -from .types.repository import ListRepositoriesRequest -from .types.repository import ListRepositoriesResponse -from .types.repository import RemoteRepositoryConfig -from .types.repository import Repository -from .types.repository import UpdateRepositoryRequest -from .types.repository import UpstreamPolicy -from .types.repository import VirtualRepositoryConfig -from .types.rule import CreateRuleRequest -from .types.rule import DeleteRuleRequest -from .types.rule import GetRuleRequest -from .types.rule import ListRulesRequest -from .types.rule import ListRulesResponse -from .types.rule import Rule -from .types.rule import UpdateRuleRequest -from .types.service import OperationMetadata -from .types.settings import GetProjectSettingsRequest -from .types.settings import ProjectSettings -from .types.settings import UpdateProjectSettingsRequest -from .types.tag import CreateTagRequest -from .types.tag import DeleteTagRequest -from .types.tag import GetTagRequest -from .types.tag import ListTagsRequest -from .types.tag import ListTagsResponse -from .types.tag import Tag -from .types.tag import UpdateTagRequest -from .types.version import BatchDeleteVersionsMetadata -from .types.version import BatchDeleteVersionsRequest -from .types.version import DeleteVersionRequest -from .types.version import GetVersionRequest -from .types.version import ListVersionsRequest -from .types.version import ListVersionsResponse -from .types.version import UpdateVersionRequest -from .types.version import Version -from .types.version import VersionView -from .types.vpcsc_config import GetVPCSCConfigRequest -from .types.vpcsc_config import UpdateVPCSCConfigRequest -from .types.vpcsc_config import VPCSCConfig -from .types.yum_artifact import ImportYumArtifactsErrorInfo -from .types.yum_artifact import ImportYumArtifactsGcsSource -from .types.yum_artifact import ImportYumArtifactsMetadata -from .types.yum_artifact import ImportYumArtifactsRequest -from .types.yum_artifact import ImportYumArtifactsResponse -from .types.yum_artifact import YumArtifact - -__all__ = ( - 'ArtifactRegistryAsyncClient', -'AptArtifact', -'ArtifactRegistryClient', -'Attachment', -'BatchDeleteVersionsMetadata', -'BatchDeleteVersionsRequest', -'CleanupPolicy', -'CleanupPolicyCondition', -'CleanupPolicyMostRecentVersions', -'CreateAttachmentRequest', -'CreateRepositoryRequest', -'CreateRuleRequest', -'CreateTagRequest', -'DeleteAttachmentRequest', -'DeleteFileRequest', -'DeletePackageRequest', -'DeleteRepositoryRequest', -'DeleteRuleRequest', -'DeleteTagRequest', -'DeleteVersionRequest', -'DockerImage', -'File', -'GenericArtifact', -'GetAttachmentRequest', -'GetDockerImageRequest', -'GetFileRequest', -'GetMavenArtifactRequest', -'GetNpmPackageRequest', -'GetPackageRequest', -'GetProjectSettingsRequest', -'GetPythonPackageRequest', -'GetRepositoryRequest', -'GetRuleRequest', -'GetTagRequest', -'GetVPCSCConfigRequest', -'GetVersionRequest', -'Hash', -'ImportAptArtifactsErrorInfo', -'ImportAptArtifactsGcsSource', -'ImportAptArtifactsMetadata', -'ImportAptArtifactsRequest', -'ImportAptArtifactsResponse', -'ImportYumArtifactsErrorInfo', -'ImportYumArtifactsGcsSource', -'ImportYumArtifactsMetadata', -'ImportYumArtifactsRequest', -'ImportYumArtifactsResponse', -'ListAttachmentsRequest', -'ListAttachmentsResponse', -'ListDockerImagesRequest', -'ListDockerImagesResponse', -'ListFilesRequest', -'ListFilesResponse', -'ListMavenArtifactsRequest', -'ListMavenArtifactsResponse', -'ListNpmPackagesRequest', -'ListNpmPackagesResponse', -'ListPackagesRequest', -'ListPackagesResponse', -'ListPythonPackagesRequest', -'ListPythonPackagesResponse', -'ListRepositoriesRequest', -'ListRepositoriesResponse', -'ListRulesRequest', -'ListRulesResponse', -'ListTagsRequest', -'ListTagsResponse', -'ListVersionsRequest', -'ListVersionsResponse', -'MavenArtifact', -'NpmPackage', -'OperationMetadata', -'Package', -'ProjectSettings', -'PythonPackage', -'RemoteRepositoryConfig', -'Repository', -'Rule', -'Tag', -'UpdateFileRequest', -'UpdatePackageRequest', -'UpdateProjectSettingsRequest', -'UpdateRepositoryRequest', -'UpdateRuleRequest', -'UpdateTagRequest', -'UpdateVPCSCConfigRequest', -'UpdateVersionRequest', -'UpstreamPolicy', -'VPCSCConfig', -'Version', -'VersionView', -'VirtualRepositoryConfig', -'YumArtifact', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/gapic_metadata.json deleted file mode 100644 index 7824e41e78fd..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/gapic_metadata.json +++ /dev/null @@ -1,763 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.artifactregistry_v1", - "protoPackage": "google.devtools.artifactregistry.v1", - "schema": "1.0", - "services": { - "ArtifactRegistry": { - "clients": { - "grpc": { - "libraryClient": "ArtifactRegistryClient", - "rpcs": { - "BatchDeleteVersions": { - "methods": [ - "batch_delete_versions" - ] - }, - "CreateAttachment": { - "methods": [ - "create_attachment" - ] - }, - "CreateRepository": { - "methods": [ - "create_repository" - ] - }, - "CreateRule": { - "methods": [ - "create_rule" - ] - }, - "CreateTag": { - "methods": [ - "create_tag" - ] - }, - "DeleteAttachment": { - "methods": [ - "delete_attachment" - ] - }, - "DeleteFile": { - "methods": [ - "delete_file" - ] - }, - "DeletePackage": { - "methods": [ - "delete_package" - ] - }, - "DeleteRepository": { - "methods": [ - "delete_repository" - ] - }, - "DeleteRule": { - "methods": [ - "delete_rule" - ] - }, - "DeleteTag": { - "methods": [ - "delete_tag" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetAttachment": { - "methods": [ - "get_attachment" - ] - }, - "GetDockerImage": { - "methods": [ - "get_docker_image" - ] - }, - "GetFile": { - "methods": [ - "get_file" - ] - }, - "GetIamPolicy": { - "methods": [ - "get_iam_policy" - ] - }, - "GetMavenArtifact": { - "methods": [ - "get_maven_artifact" - ] - }, - "GetNpmPackage": { - "methods": [ - "get_npm_package" - ] - }, - "GetPackage": { - "methods": [ - "get_package" - ] - }, - "GetProjectSettings": { - "methods": [ - "get_project_settings" - ] - }, - "GetPythonPackage": { - "methods": [ - "get_python_package" - ] - }, - "GetRepository": { - "methods": [ - "get_repository" - ] - }, - "GetRule": { - "methods": [ - "get_rule" - ] - }, - "GetTag": { - "methods": [ - "get_tag" - ] - }, - "GetVPCSCConfig": { - "methods": [ - "get_vpcsc_config" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ImportAptArtifacts": { - "methods": [ - "import_apt_artifacts" - ] - }, - "ImportYumArtifacts": { - "methods": [ - "import_yum_artifacts" - ] - }, - "ListAttachments": { - "methods": [ - "list_attachments" - ] - }, - "ListDockerImages": { - "methods": [ - "list_docker_images" - ] - }, - "ListFiles": { - "methods": [ - "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" - ] - }, - "ListRules": { - "methods": [ - "list_rules" - ] - }, - "ListTags": { - "methods": [ - "list_tags" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "SetIamPolicy": { - "methods": [ - "set_iam_policy" - ] - }, - "TestIamPermissions": { - "methods": [ - "test_iam_permissions" - ] - }, - "UpdateFile": { - "methods": [ - "update_file" - ] - }, - "UpdatePackage": { - "methods": [ - "update_package" - ] - }, - "UpdateProjectSettings": { - "methods": [ - "update_project_settings" - ] - }, - "UpdateRepository": { - "methods": [ - "update_repository" - ] - }, - "UpdateRule": { - "methods": [ - "update_rule" - ] - }, - "UpdateTag": { - "methods": [ - "update_tag" - ] - }, - "UpdateVPCSCConfig": { - "methods": [ - "update_vpcsc_config" - ] - }, - "UpdateVersion": { - "methods": [ - "update_version" - ] - } - } - }, - "grpc-async": { - "libraryClient": "ArtifactRegistryAsyncClient", - "rpcs": { - "BatchDeleteVersions": { - "methods": [ - "batch_delete_versions" - ] - }, - "CreateAttachment": { - "methods": [ - "create_attachment" - ] - }, - "CreateRepository": { - "methods": [ - "create_repository" - ] - }, - "CreateRule": { - "methods": [ - "create_rule" - ] - }, - "CreateTag": { - "methods": [ - "create_tag" - ] - }, - "DeleteAttachment": { - "methods": [ - "delete_attachment" - ] - }, - "DeleteFile": { - "methods": [ - "delete_file" - ] - }, - "DeletePackage": { - "methods": [ - "delete_package" - ] - }, - "DeleteRepository": { - "methods": [ - "delete_repository" - ] - }, - "DeleteRule": { - "methods": [ - "delete_rule" - ] - }, - "DeleteTag": { - "methods": [ - "delete_tag" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetAttachment": { - "methods": [ - "get_attachment" - ] - }, - "GetDockerImage": { - "methods": [ - "get_docker_image" - ] - }, - "GetFile": { - "methods": [ - "get_file" - ] - }, - "GetIamPolicy": { - "methods": [ - "get_iam_policy" - ] - }, - "GetMavenArtifact": { - "methods": [ - "get_maven_artifact" - ] - }, - "GetNpmPackage": { - "methods": [ - "get_npm_package" - ] - }, - "GetPackage": { - "methods": [ - "get_package" - ] - }, - "GetProjectSettings": { - "methods": [ - "get_project_settings" - ] - }, - "GetPythonPackage": { - "methods": [ - "get_python_package" - ] - }, - "GetRepository": { - "methods": [ - "get_repository" - ] - }, - "GetRule": { - "methods": [ - "get_rule" - ] - }, - "GetTag": { - "methods": [ - "get_tag" - ] - }, - "GetVPCSCConfig": { - "methods": [ - "get_vpcsc_config" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ImportAptArtifacts": { - "methods": [ - "import_apt_artifacts" - ] - }, - "ImportYumArtifacts": { - "methods": [ - "import_yum_artifacts" - ] - }, - "ListAttachments": { - "methods": [ - "list_attachments" - ] - }, - "ListDockerImages": { - "methods": [ - "list_docker_images" - ] - }, - "ListFiles": { - "methods": [ - "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" - ] - }, - "ListRules": { - "methods": [ - "list_rules" - ] - }, - "ListTags": { - "methods": [ - "list_tags" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "SetIamPolicy": { - "methods": [ - "set_iam_policy" - ] - }, - "TestIamPermissions": { - "methods": [ - "test_iam_permissions" - ] - }, - "UpdateFile": { - "methods": [ - "update_file" - ] - }, - "UpdatePackage": { - "methods": [ - "update_package" - ] - }, - "UpdateProjectSettings": { - "methods": [ - "update_project_settings" - ] - }, - "UpdateRepository": { - "methods": [ - "update_repository" - ] - }, - "UpdateRule": { - "methods": [ - "update_rule" - ] - }, - "UpdateTag": { - "methods": [ - "update_tag" - ] - }, - "UpdateVPCSCConfig": { - "methods": [ - "update_vpcsc_config" - ] - }, - "UpdateVersion": { - "methods": [ - "update_version" - ] - } - } - }, - "rest": { - "libraryClient": "ArtifactRegistryClient", - "rpcs": { - "BatchDeleteVersions": { - "methods": [ - "batch_delete_versions" - ] - }, - "CreateAttachment": { - "methods": [ - "create_attachment" - ] - }, - "CreateRepository": { - "methods": [ - "create_repository" - ] - }, - "CreateRule": { - "methods": [ - "create_rule" - ] - }, - "CreateTag": { - "methods": [ - "create_tag" - ] - }, - "DeleteAttachment": { - "methods": [ - "delete_attachment" - ] - }, - "DeleteFile": { - "methods": [ - "delete_file" - ] - }, - "DeletePackage": { - "methods": [ - "delete_package" - ] - }, - "DeleteRepository": { - "methods": [ - "delete_repository" - ] - }, - "DeleteRule": { - "methods": [ - "delete_rule" - ] - }, - "DeleteTag": { - "methods": [ - "delete_tag" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetAttachment": { - "methods": [ - "get_attachment" - ] - }, - "GetDockerImage": { - "methods": [ - "get_docker_image" - ] - }, - "GetFile": { - "methods": [ - "get_file" - ] - }, - "GetIamPolicy": { - "methods": [ - "get_iam_policy" - ] - }, - "GetMavenArtifact": { - "methods": [ - "get_maven_artifact" - ] - }, - "GetNpmPackage": { - "methods": [ - "get_npm_package" - ] - }, - "GetPackage": { - "methods": [ - "get_package" - ] - }, - "GetProjectSettings": { - "methods": [ - "get_project_settings" - ] - }, - "GetPythonPackage": { - "methods": [ - "get_python_package" - ] - }, - "GetRepository": { - "methods": [ - "get_repository" - ] - }, - "GetRule": { - "methods": [ - "get_rule" - ] - }, - "GetTag": { - "methods": [ - "get_tag" - ] - }, - "GetVPCSCConfig": { - "methods": [ - "get_vpcsc_config" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ImportAptArtifacts": { - "methods": [ - "import_apt_artifacts" - ] - }, - "ImportYumArtifacts": { - "methods": [ - "import_yum_artifacts" - ] - }, - "ListAttachments": { - "methods": [ - "list_attachments" - ] - }, - "ListDockerImages": { - "methods": [ - "list_docker_images" - ] - }, - "ListFiles": { - "methods": [ - "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" - ] - }, - "ListRules": { - "methods": [ - "list_rules" - ] - }, - "ListTags": { - "methods": [ - "list_tags" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "SetIamPolicy": { - "methods": [ - "set_iam_policy" - ] - }, - "TestIamPermissions": { - "methods": [ - "test_iam_permissions" - ] - }, - "UpdateFile": { - "methods": [ - "update_file" - ] - }, - "UpdatePackage": { - "methods": [ - "update_package" - ] - }, - "UpdateProjectSettings": { - "methods": [ - "update_project_settings" - ] - }, - "UpdateRepository": { - "methods": [ - "update_repository" - ] - }, - "UpdateRule": { - "methods": [ - "update_rule" - ] - }, - "UpdateTag": { - "methods": [ - "update_tag" - ] - }, - "UpdateVPCSCConfig": { - "methods": [ - "update_vpcsc_config" - ] - }, - "UpdateVersion": { - "methods": [ - "update_version" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/gapic_version.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/gapic_version.py deleted file mode 100644 index 558c8aab67c5..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/py.typed b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/py.typed deleted file mode 100644 index 7ee239890682..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-artifact-registry package uses inline types. diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/__init__.py deleted file mode 100644 index 8f6cf068242c..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/__init__.py deleted file mode 100644 index e174d42fd497..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 .client import ArtifactRegistryClient -from .async_client import ArtifactRegistryAsyncClient - -__all__ = ( - 'ArtifactRegistryClient', - 'ArtifactRegistryAsyncClient', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py deleted file mode 100644 index 8c2f16c1d0c6..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py +++ /dev/null @@ -1,5983 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 collections import OrderedDict -import re -from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union - -from google.cloud.artifactregistry_v1 import gapic_version as package_version - -from google.api_core.client_options import ClientOptions -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry_async as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - - -try: - OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.artifactregistry_v1.services.artifact_registry import pagers -from google.cloud.artifactregistry_v1.types import apt_artifact -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import attachment as gda_attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import file as gda_file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import package as gda_package -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 rule -from google.cloud.artifactregistry_v1.types import rule as gda_rule -from google.cloud.artifactregistry_v1.types import service -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 -from google.cloud.artifactregistry_v1.types import version as gda_version -from google.cloud.artifactregistry_v1.types import vpcsc_config -from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config -from google.cloud.artifactregistry_v1.types import yum_artifact -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 # type: ignore -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 -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import expr_pb2 # type: ignore -from .transports.base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport -from .client import ArtifactRegistryClient - - -class ArtifactRegistryAsyncClient: - """The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - """ - - _client: ArtifactRegistryClient - - # Copy defaults from the synchronous client for use here. - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = ArtifactRegistryClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - _DEFAULT_ENDPOINT_TEMPLATE = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE - _DEFAULT_UNIVERSE = ArtifactRegistryClient._DEFAULT_UNIVERSE - - apt_artifact_path = staticmethod(ArtifactRegistryClient.apt_artifact_path) - parse_apt_artifact_path = staticmethod(ArtifactRegistryClient.parse_apt_artifact_path) - attachment_path = staticmethod(ArtifactRegistryClient.attachment_path) - parse_attachment_path = staticmethod(ArtifactRegistryClient.parse_attachment_path) - docker_image_path = staticmethod(ArtifactRegistryClient.docker_image_path) - parse_docker_image_path = staticmethod(ArtifactRegistryClient.parse_docker_image_path) - 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) - rule_path = staticmethod(ArtifactRegistryClient.rule_path) - parse_rule_path = staticmethod(ArtifactRegistryClient.parse_rule_path) - secret_version_path = staticmethod(ArtifactRegistryClient.secret_version_path) - parse_secret_version_path = staticmethod(ArtifactRegistryClient.parse_secret_version_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) - common_billing_account_path = staticmethod(ArtifactRegistryClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(ArtifactRegistryClient.parse_common_billing_account_path) - common_folder_path = staticmethod(ArtifactRegistryClient.common_folder_path) - parse_common_folder_path = staticmethod(ArtifactRegistryClient.parse_common_folder_path) - common_organization_path = staticmethod(ArtifactRegistryClient.common_organization_path) - parse_common_organization_path = staticmethod(ArtifactRegistryClient.parse_common_organization_path) - common_project_path = staticmethod(ArtifactRegistryClient.common_project_path) - parse_common_project_path = staticmethod(ArtifactRegistryClient.parse_common_project_path) - common_location_path = staticmethod(ArtifactRegistryClient.common_location_path) - parse_common_location_path = staticmethod(ArtifactRegistryClient.parse_common_location_path) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ArtifactRegistryAsyncClient: The constructed client. - """ - return ArtifactRegistryClient.from_service_account_info.__func__(ArtifactRegistryAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ArtifactRegistryAsyncClient: The constructed client. - """ - return ArtifactRegistryClient.from_service_account_file.__func__(ArtifactRegistryAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[ClientOptions] = None): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - return ArtifactRegistryClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> ArtifactRegistryTransport: - """Returns the transport used by the client instance. - - Returns: - ArtifactRegistryTransport: The transport used by the client instance. - """ - return self._client.transport - - @property - def api_endpoint(self): - """Return the API endpoint used by the client instance. - - Returns: - str: The API endpoint used by the client instance. - """ - return self._client._api_endpoint - - @property - def universe_domain(self) -> str: - """Return the universe domain used by the client instance. - - Returns: - str: The universe domain used - by the client instance. - """ - return self._client._universe_domain - - get_transport_class = ArtifactRegistryClient.get_transport_class - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, ArtifactRegistryTransport, Callable[..., ArtifactRegistryTransport]]] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the artifact registry async client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Optional[Union[str,ArtifactRegistryTransport,Callable[..., ArtifactRegistryTransport]]]): - The transport to use, or a Callable that constructs and returns a new transport to use. - If a Callable is given, it will be called with the same set of initialization - arguments as used in the ArtifactRegistryTransport constructor. - If set to None, a transport is chosen automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): - Custom options for the client. - - 1. The ``api_endpoint`` property can be used to override the - default endpoint provided by the client when ``transport`` is - not explicitly provided. Only if this property is not set and - ``transport`` was not explicitly provided, the endpoint is - determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment - variable, which have one of the following values: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto-switch to the - default mTLS endpoint if client certificate is present; this is - the default value). - - 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide a client certificate for mTLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - 3. The ``universe_domain`` property can be used to override the - default "googleapis.com" universe. Note that ``api_endpoint`` - property still takes precedence; and ``universe_domain`` is - currently not supported for mTLS. - - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = ArtifactRegistryClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_docker_images(self, - request: Optional[Union[artifact.ListDockerImagesRequest, 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.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_async.AsyncRetry): 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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._client._transport._wrapped_methods[self._client._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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - retry=retry, - timeout=timeout, - 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_async.AsyncRetry): 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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._client._transport._wrapped_methods[self._client._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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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_async.AsyncRetry): 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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._client._transport._wrapped_methods[self._client._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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - retry=retry, - timeout=timeout, - 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_async.AsyncRetry): 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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._client._transport._wrapped_methods[self._client._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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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_async.AsyncRetry): 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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._client._transport._wrapped_methods[self._client._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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - retry=retry, - timeout=timeout, - 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_async.AsyncRetry): 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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._client._transport._wrapped_methods[self._client._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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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 - - # 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) - - Args: - 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 python 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_async.AsyncRetry): 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.ListPythonPackagesAsyncPager: - The response from listing python - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_python_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListPythonPackagesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_python_package(self, - 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.PythonPackage: - r"""Gets a python 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_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) - - Args: - 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 python - 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_async.AsyncRetry): 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.PythonPackage: - PythonPackage represents a python - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_python_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def import_apt_artifacts(self, - request: Optional[Union[apt_artifact.ImportAptArtifactsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Imports Apt artifacts. The returned Operation will - complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - .. 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_import_apt_artifacts(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ImportAptArtifactsRequest( - ) - - # Make the request - operation = client.import_apt_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest, dict]]): - The request object. The request to import new apt - artifacts. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1.types.ImportAptArtifactsResponse` - The response message from importing APT artifacts. - - """ - # Create or coerce a protobuf request object. - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, apt_artifact.ImportAptArtifactsRequest): - request = apt_artifact.ImportAptArtifactsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.import_apt_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - apt_artifact.ImportAptArtifactsResponse, - metadata_type=apt_artifact.ImportAptArtifactsMetadata, - ) - - # Done; return the response. - return response - - async def import_yum_artifacts(self, - request: Optional[Union[yum_artifact.ImportYumArtifactsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Imports Yum (RPM) artifacts. The returned Operation - will complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - .. 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_import_yum_artifacts(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ImportYumArtifactsRequest( - ) - - # Make the request - operation = client.import_yum_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest, dict]]): - The request object. The request to import new yum - artifacts. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1.types.ImportYumArtifactsResponse` - The response message from importing YUM artifacts. - - """ - # Create or coerce a protobuf request object. - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, yum_artifact.ImportYumArtifactsRequest): - request = yum_artifact.ImportYumArtifactsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.import_yum_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - yum_artifact.ImportYumArtifactsResponse, - metadata_type=yum_artifact.ImportYumArtifactsMetadata, - ) - - # Done; return the response. - return response - - async def list_repositories(self, - request: Optional[Union[repository.ListRepositoriesRequest, 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.ListRepositoriesAsyncPager: - r"""Lists repositories. - - .. 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_repositories(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListRepositoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_repositories(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListRepositoriesRequest, dict]]): - The request object. The request to list repositories. - parent (:class:`str`): - Required. The name of the parent - resource whose repositories 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_async.AsyncRetry): 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.ListRepositoriesAsyncPager: - The response from listing - repositories. - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.ListRepositoriesRequest): - request = repository.ListRepositoriesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_repositories] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListRepositoriesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_repository(self, - request: Optional[Union[repository.GetRepositoryRequest, 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]] = (), - ) -> repository.Repository: - r"""Gets a repository. - - .. 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_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetRepositoryRequest( - name="name_value", - ) - - # Make the request - response = await client.get_repository(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetRepositoryRequest, dict]]): - The request object. The request to retrieve a repository. - name (:class:`str`): - Required. The name of the repository - to retrieve. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.Repository: - A Repository for storing artifacts - with a specific format. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.GetRepositoryRequest): - request = repository.GetRepositoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_repository(self, - request: Optional[Union[gda_repository.CreateRepositoryRequest, dict]] = None, - *, - parent: Optional[str] = None, - repository: Optional[gda_repository.Repository] = None, - repository_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a repository. The returned Operation will - finish once the repository has been created. Its - response will be the created Repository. - - .. 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_create_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateRepositoryRequest( - parent="parent_value", - repository_id="repository_id_value", - ) - - # Make the request - operation = client.create_repository(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.CreateRepositoryRequest, dict]]): - The request object. The request to create a new - repository. - parent (:class:`str`): - Required. The name of the parent - resource where the repository will be - created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - repository (:class:`google.cloud.artifactregistry_v1.types.Repository`): - Required. The repository to be - created. - - This corresponds to the ``repository`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - repository_id (:class:`str`): - Required. The repository id to use - for this repository. - - This corresponds to the ``repository_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1.types.Repository` - A Repository for storing artifacts with a specific - format. - - """ - # 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, repository, repository_id]) - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_repository.CreateRepositoryRequest): - request = gda_repository.CreateRepositoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if repository is not None: - request.repository = repository - if repository_id is not None: - request.repository_id = repository_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - gda_repository.Repository, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_repository(self, - request: Optional[Union[gda_repository.UpdateRepositoryRequest, dict]] = None, - *, - repository: Optional[gda_repository.Repository] = 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_repository.Repository: - r"""Updates a repository. - - .. 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_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateRepositoryRequest( - ) - - # Make the request - response = await client.update_repository(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateRepositoryRequest, dict]]): - The request object. The request to update a repository. - repository (:class:`google.cloud.artifactregistry_v1.types.Repository`): - The repository that replaces the - resource on the server. - - This corresponds to the ``repository`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): 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.Repository: - A Repository for storing artifacts - with a specific format. - - """ - # 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([repository, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_repository.UpdateRepositoryRequest): - request = gda_repository.UpdateRepositoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if repository is not None: - request.repository = repository - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.update_repository] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("repository.name", request.repository.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_repository(self, - request: Optional[Union[repository.DeleteRepositoryRequest, 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a repository and all of its contents. The - returned Operation will finish once the repository has - been deleted. It will not have any Operation metadata - and will return a google.protobuf.Empty response. - - .. 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_delete_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteRepositoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_repository(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteRepositoryRequest, dict]]): - The request object. The request to delete a repository. - name (:class:`str`): - Required. The name of the repository - to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.DeleteRepositoryRequest): - request = repository.DeleteRepositoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.delete_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_packages(self, - request: Optional[Union[package.ListPackagesRequest, 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.ListPackagesAsyncPager: - r"""Lists 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_packages(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListPackagesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_packages(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListPackagesRequest, dict]]): - The request object. The request to list packages. - parent (:class:`str`): - Required. The name of the parent - resource whose 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_async.AsyncRetry): 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.ListPackagesAsyncPager: - The response from listing 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.ListPackagesRequest): - request = package.ListPackagesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListPackagesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_package(self, - request: Optional[Union[package.GetPackageRequest, 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]] = (), - ) -> package.Package: - r"""Gets a 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_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetPackageRequest( - name="name_value", - ) - - # Make the request - response = await client.get_package(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetPackageRequest, dict]]): - The request object. The request to retrieve a package. - name (:class:`str`): - Required. The name of the package to - retrieve. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.Package: - Packages are named collections of - versions. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.GetPackageRequest): - request = package.GetPackageRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_package(self, - request: Optional[Union[package.DeletePackageRequest, 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a package and all of its versions and tags. - The returned operation will complete once the package - has been deleted. - - .. 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_delete_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeletePackageRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_package(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.DeletePackageRequest, dict]]): - The request object. The request to delete a package. - name (:class:`str`): - Required. The name of the package to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.DeletePackageRequest): - request = package.DeletePackageRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.delete_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_versions(self, - request: Optional[Union[version.ListVersionsRequest, 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.ListVersionsAsyncPager: - r"""Lists versions. - - .. 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_versions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListVersionsRequest( - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListVersionsRequest, dict]]): - The request object. The request to list versions. - parent (:class:`str`): - The name of the parent resource whose - versions 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_async.AsyncRetry): 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.ListVersionsAsyncPager: - The response from listing versions. - - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.ListVersionsRequest): - request = version.ListVersionsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_versions] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListVersionsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_version(self, - request: Optional[Union[version.GetVersionRequest, 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]] = (), - ) -> version.Version: - r"""Gets a version - - .. 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_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetVersionRequest( - ) - - # Make the request - response = await client.get_version(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetVersionRequest, dict]]): - The request object. The request to retrieve a version. - name (:class:`str`): - The name of the version to retrieve. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.GetVersionRequest): - request = version.GetVersionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_version] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_version(self, - request: Optional[Union[version.DeleteVersionRequest, 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a version and all of its content. The - returned operation will complete once the version has - been deleted. - - .. 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_delete_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteVersionRequest( - ) - - # Make the request - operation = client.delete_version(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteVersionRequest, dict]]): - The request object. The request to delete a version. - name (:class:`str`): - The name of the version to delete. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.DeleteVersionRequest): - request = version.DeleteVersionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.delete_version] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def batch_delete_versions(self, - request: Optional[Union[version.BatchDeleteVersionsRequest, dict]] = None, - *, - parent: Optional[str] = None, - names: Optional[MutableSequence[str]] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes multiple versions across a repository. The - returned operation will complete once the versions have - been deleted. - - .. 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_batch_delete_versions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.BatchDeleteVersionsRequest( - names=['names_value1', 'names_value2'], - ) - - # Make the request - operation = client.batch_delete_versions(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.BatchDeleteVersionsRequest, dict]]): - The request object. The request to delete multiple - versions across a repository. - parent (:class:`str`): - The name of the repository holding - all requested versions. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - names (:class:`MutableSequence[str]`): - Required. The names of the versions - to delete. A maximum of 10000 versions - can be deleted in a batch. - - This corresponds to the ``names`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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, names]) - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.BatchDeleteVersionsRequest): - request = version.BatchDeleteVersionsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if names: - request.names.extend(names) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.batch_delete_versions] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=version.BatchDeleteVersionsMetadata, - ) - - # Done; return the response. - return response - - async def update_version(self, - request: Optional[Union[gda_version.UpdateVersionRequest, dict]] = None, - *, - version: Optional[gda_version.Version] = 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_version.Version: - r"""Updates a version. - - .. 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_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateVersionRequest( - ) - - # Make the request - response = await client.update_version(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateVersionRequest, dict]]): - The request object. The request to update a version. - version (:class:`google.cloud.artifactregistry_v1.types.Version`): - Required. The Version that replaces - the resource on the server. - - This corresponds to the ``version`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): 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.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - # 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([version, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_version.UpdateVersionRequest): - request = gda_version.UpdateVersionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if version is not None: - request.version = version - 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._client._transport._wrapped_methods[self._client._transport.update_version] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("version.name", request.version.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_files(self, - request: Optional[Union[file.ListFilesRequest, 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.ListFilesAsyncPager: - r"""Lists files. - - .. 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_files(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListFilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_files(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListFilesRequest, dict]]): - The request object. The request to list files. - parent (:class:`str`): - 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 - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.ListFilesAsyncPager: - The response from listing files. - - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.ListFilesRequest): - request = file.ListFilesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_files] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListFilesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_file(self, - request: Optional[Union[file.GetFileRequest, 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]] = (), - ) -> file.File: - r"""Gets a file. - - .. 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_file(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetFileRequest( - name="name_value", - ) - - # Make the request - response = await client.get_file(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetFileRequest, dict]]): - The request object. The request to retrieve a file. - name (:class:`str`): - 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. - retry (google.api_core.retry_async.AsyncRetry): 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.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.GetFileRequest): - request = file.GetFileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_file] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_file(self, - request: Optional[Union[file.DeleteFileRequest, 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a file and all of its content. It is only - allowed on generic repositories. The returned operation - will complete once the file has been deleted. - - .. 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_delete_file(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteFileRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_file(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteFileRequest, dict]]): - The request object. The request to delete a file. - name (:class:`str`): - Required. The name of the file to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.DeleteFileRequest): - request = file.DeleteFileRequest(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._client._transport._wrapped_methods[self._client._transport.delete_file] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_file(self, - request: Optional[Union[gda_file.UpdateFileRequest, dict]] = None, - *, - file: Optional[gda_file.File] = 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_file.File: - r"""Updates a file. - - .. 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_file(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateFileRequest( - ) - - # Make the request - response = await client.update_file(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateFileRequest, dict]]): - The request object. The request to update a file. - file (:class:`google.cloud.artifactregistry_v1.types.File`): - Required. The File that replaces the - resource on the server. - - This corresponds to the ``file`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): 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.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - # 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([file, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_file.UpdateFileRequest): - request = gda_file.UpdateFileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if file is not None: - request.file = file - 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._client._transport._wrapped_methods[self._client._transport.update_file] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("file.name", request.file.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_tags(self, - request: Optional[Union[tag.ListTagsRequest, 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.ListTagsAsyncPager: - r"""Lists tags. - - .. 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_tags(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListTagsRequest( - ) - - # Make the request - page_result = client.list_tags(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListTagsRequest, dict]]): - The request object. The request to list tags. - parent (:class:`str`): - The name of the parent package whose tags will be - listed. For example: - ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.ListTagsAsyncPager: - The response from listing tags. - - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.ListTagsRequest): - request = tag.ListTagsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_tags] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListTagsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_tag(self, - request: Optional[Union[tag.GetTagRequest, 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]] = (), - ) -> tag.Tag: - r"""Gets a tag. - - .. 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_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetTagRequest( - ) - - # Make the request - response = await client.get_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetTagRequest, dict]]): - The request object. The request to retrieve a tag. - name (:class:`str`): - The name of the tag to retrieve. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.GetTagRequest): - request = tag.GetTagRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_tag(self, - request: Optional[Union[gda_tag.CreateTagRequest, dict]] = None, - *, - parent: Optional[str] = None, - tag: Optional[gda_tag.Tag] = None, - tag_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gda_tag.Tag: - r"""Creates a tag. - - .. 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_create_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateTagRequest( - ) - - # Make the request - response = await client.create_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.CreateTagRequest, dict]]): - The request object. The request to create a new tag. - parent (:class:`str`): - The name of the parent resource where - the tag will be created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag (:class:`google.cloud.artifactregistry_v1.types.Tag`): - The tag to be created. - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag_id (:class:`str`): - The tag id to use for this - repository. - - This corresponds to the ``tag_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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, tag, tag_id]) - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_tag.CreateTagRequest): - request = gda_tag.CreateTagRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if tag is not None: - request.tag = tag - if tag_id is not None: - request.tag_id = tag_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_tag(self, - request: Optional[Union[gda_tag.UpdateTagRequest, dict]] = None, - *, - tag: Optional[gda_tag.Tag] = 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_tag.Tag: - r"""Updates a tag. - - .. 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_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateTagRequest( - ) - - # Make the request - response = await client.update_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateTagRequest, dict]]): - The request object. The request to create or update a - tag. - tag (:class:`google.cloud.artifactregistry_v1.types.Tag`): - The tag that replaces the resource on - the server. - - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): 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.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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([tag, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_tag.UpdateTagRequest): - request = gda_tag.UpdateTagRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if tag is not None: - request.tag = tag - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.update_tag] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("tag.name", request.tag.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_tag(self, - request: Optional[Union[tag.DeleteTagRequest, 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]] = (), - ) -> None: - r"""Deletes a tag. - - .. 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_delete_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteTagRequest( - ) - - # Make the request - await client.delete_tag(request=request) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteTagRequest, dict]]): - The request object. The request to delete a tag. - name (:class:`str`): - The name of the tag to delete. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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. - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.DeleteTagRequest): - request = tag.DeleteTagRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.delete_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def create_rule(self, - request: Optional[Union[gda_rule.CreateRuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - rule: Optional[gda_rule.Rule] = None, - rule_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gda_rule.Rule: - r"""Creates a rule. - - .. 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_create_rule(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateRuleRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_rule(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.CreateRuleRequest, dict]]): - The request object. The request to create a new rule. - parent (:class:`str`): - Required. The name of the parent - resource where the rule will be created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - rule (:class:`google.cloud.artifactregistry_v1.types.Rule`): - The rule to be created. - This corresponds to the ``rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - rule_id (:class:`str`): - The rule id to use for this - repository. - - This corresponds to the ``rule_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - # 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, rule, rule_id]) - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_rule.CreateRuleRequest): - request = gda_rule.CreateRuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if rule is not None: - request.rule = rule - if rule_id is not None: - request.rule_id = rule_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_rule] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_rules(self, - request: Optional[Union[rule.ListRulesRequest, 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.ListRulesAsyncPager: - r"""Lists rules. - - .. 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_rules(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListRulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_rules(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListRulesRequest, dict]]): - The request object. The request to list rules. - parent (:class:`str`): - Required. The name of the parent repository whose rules - will be listed. For example: - ``projects/p1/locations/us-central1/repositories/repo1``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.ListRulesAsyncPager: - The response from listing rules. - - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, rule.ListRulesRequest): - request = rule.ListRulesRequest(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._client._transport._wrapped_methods[self._client._transport.list_rules] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListRulesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_rule(self, - request: Optional[Union[rule.GetRuleRequest, 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]] = (), - ) -> rule.Rule: - r"""Gets a rule. - - .. 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_rule(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetRuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_rule(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetRuleRequest, dict]]): - The request object. The request to retrieve a rule. - name (:class:`str`): - Required. The name of the rule to - retrieve. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, rule.GetRuleRequest): - request = rule.GetRuleRequest(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._client._transport._wrapped_methods[self._client._transport.get_rule] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_rule(self, - request: Optional[Union[gda_rule.UpdateRuleRequest, dict]] = None, - *, - rule: Optional[gda_rule.Rule] = 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_rule.Rule: - r"""Updates a rule. - - .. 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_rule(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateRuleRequest( - ) - - # Make the request - response = await client.update_rule(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateRuleRequest, dict]]): - The request object. The request to update a rule. - rule (:class:`google.cloud.artifactregistry_v1.types.Rule`): - The rule that replaces the resource - on the server. - - This corresponds to the ``rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): 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.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - # 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([rule, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_rule.UpdateRuleRequest): - request = gda_rule.UpdateRuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if rule is not None: - request.rule = rule - 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._client._transport._wrapped_methods[self._client._transport.update_rule] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("rule.name", request.rule.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_rule(self, - request: Optional[Union[rule.DeleteRuleRequest, 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]] = (), - ) -> None: - r"""Deletes a rule. - - .. 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_delete_rule(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteRuleRequest( - name="name_value", - ) - - # Make the request - await client.delete_rule(request=request) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteRuleRequest, dict]]): - The request object. The request to delete a rule. - name (:class:`str`): - Required. The name of the rule to - delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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. - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, rule.DeleteRuleRequest): - request = rule.DeleteRuleRequest(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._client._transport._wrapped_methods[self._client._transport.delete_rule] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def set_iam_policy(self, - request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Updates the IAM policy for a given resource. - - .. 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 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - async def sample_set_iam_policy(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = await client.set_iam_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]): - The request object. Request message for ``SetIamPolicy`` method. - retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). - - """ - # Create or coerce a protobuf request object. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.SetIamPolicyRequest(**request) - elif not request: - request = iam_policy_pb2.SetIamPolicyRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.set_iam_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_iam_policy(self, - request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Gets the IAM policy for a given resource. - - .. 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 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - async def sample_get_iam_policy(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = await client.get_iam_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]): - The request object. Request message for ``GetIamPolicy`` method. - retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). - - """ - # Create or coerce a protobuf request object. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.GetIamPolicyRequest(**request) - elif not request: - request = iam_policy_pb2.GetIamPolicyRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_iam_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def test_iam_permissions(self, - request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Tests if the caller has a list of permissions on a - resource. - - .. 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 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - async def sample_test_iam_permissions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], - ) - - # Make the request - response = await client.test_iam_permissions(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]): - The request object. Request message for ``TestIamPermissions`` method. - retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: - Response message for TestIamPermissions method. - """ - # Create or coerce a protobuf request object. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.TestIamPermissionsRequest(**request) - elif not request: - request = iam_policy_pb2.TestIamPermissionsRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.test_iam_permissions] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_project_settings(self, - request: Optional[Union[settings.GetProjectSettingsRequest, 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]] = (), - ) -> settings.ProjectSettings: - r"""Retrieves the Settings 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_project_settings(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetProjectSettingsRequest( - name="name_value", - ) - - # Make the request - response = await client.get_project_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest, dict]]): - The request object. Gets the redirection status for a - project. - name (:class:`str`): - Required. The name of the - projectSettings 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_async.AsyncRetry): 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.ProjectSettings: - The Artifact Registry settings 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, settings.GetProjectSettingsRequest): - request = settings.GetProjectSettingsRequest(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._client._transport._wrapped_methods[self._client._transport.get_project_settings] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_project_settings(self, - request: Optional[Union[settings.UpdateProjectSettingsRequest, dict]] = None, - *, - project_settings: Optional[settings.ProjectSettings] = 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]] = (), - ) -> settings.ProjectSettings: - r"""Updates the Settings 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_project_settings(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateProjectSettingsRequest( - ) - - # Make the request - response = await client.update_project_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest, dict]]): - The request object. Sets the settings of the project. - project_settings (:class:`google.cloud.artifactregistry_v1.types.ProjectSettings`): - The project settings. - This corresponds to the ``project_settings`` 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_async.AsyncRetry): 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.ProjectSettings: - The Artifact Registry settings 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([project_settings, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, settings.UpdateProjectSettingsRequest): - request = settings.UpdateProjectSettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if project_settings is not None: - request.project_settings = project_settings - 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._client._transport._wrapped_methods[self._client._transport.update_project_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("project_settings.name", request.project_settings.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # 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_async.AsyncRetry): 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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._client._transport._wrapped_methods[self._client._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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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_async.AsyncRetry): 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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._client._transport._wrapped_methods[self._client._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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_package(self, - request: Optional[Union[gda_package.UpdatePackageRequest, dict]] = None, - *, - package: Optional[gda_package.Package] = 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_package.Package: - r"""Updates a 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_update_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdatePackageRequest( - ) - - # Make the request - response = await client.update_package(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdatePackageRequest, dict]]): - The request object. The request to update a package. - package (:class:`google.cloud.artifactregistry_v1.types.Package`): - The package that replaces the - resource on the server. - - This corresponds to the ``package`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): 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.Package: - Packages are named collections of - versions. - - """ - # 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([package, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_package.UpdatePackageRequest): - request = gda_package.UpdatePackageRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if package is not None: - request.package = package - 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._client._transport._wrapped_methods[self._client._transport.update_package] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("package.name", request.package.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_attachments(self, - request: Optional[Union[attachment.ListAttachmentsRequest, 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.ListAttachmentsAsyncPager: - r"""Lists attachments. - - .. 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_attachments(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListAttachmentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_attachments(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListAttachmentsRequest, dict]]): - The request object. The request to list attachments. - parent (:class:`str`): - Required. The name of the parent - resource whose attachments 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_async.AsyncRetry): 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.ListAttachmentsAsyncPager: - The response from listing - attachments. - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, attachment.ListAttachmentsRequest): - request = attachment.ListAttachmentsRequest(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._client._transport._wrapped_methods[self._client._transport.list_attachments] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListAttachmentsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_attachment(self, - request: Optional[Union[attachment.GetAttachmentRequest, 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]] = (), - ) -> attachment.Attachment: - r"""Gets an attachment. - - .. 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_attachment(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetAttachmentRequest( - name="name_value", - ) - - # Make the request - response = await client.get_attachment(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetAttachmentRequest, dict]]): - The request object. The request to retrieve an - attachment. - name (:class:`str`): - Required. The name of the attachment - to retrieve. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.Attachment: - An Attachment refers to additional - metadata that can be attached to - artifacts in Artifact Registry. An - attachment consists of one or more - files. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, attachment.GetAttachmentRequest): - request = attachment.GetAttachmentRequest(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._client._transport._wrapped_methods[self._client._transport.get_attachment] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_attachment(self, - request: Optional[Union[gda_attachment.CreateAttachmentRequest, dict]] = None, - *, - parent: Optional[str] = None, - attachment: Optional[gda_attachment.Attachment] = None, - attachment_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates an attachment. The returned Operation will - finish once the attachment has been created. Its - response will be the created attachment. - - .. 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_create_attachment(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - attachment = artifactregistry_v1.Attachment() - attachment.target = "target_value" - attachment.files = ['files_value1', 'files_value2'] - - request = artifactregistry_v1.CreateAttachmentRequest( - parent="parent_value", - attachment_id="attachment_id_value", - attachment=attachment, - ) - - # Make the request - operation = client.create_attachment(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.CreateAttachmentRequest, dict]]): - The request object. The request to create a new - attachment. - parent (:class:`str`): - Required. The name of the parent - resource where the attachment will be - created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - attachment (:class:`google.cloud.artifactregistry_v1.types.Attachment`): - Required. The attachment to be - created. - - This corresponds to the ``attachment`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - attachment_id (:class:`str`): - Required. The attachment id to use - for this attachment. - - This corresponds to the ``attachment_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.artifactregistry_v1.types.Attachment` An Attachment refers to additional metadata that can be attached to - artifacts in Artifact Registry. An attachment - consists of one or more files. - - """ - # 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, attachment, attachment_id]) - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_attachment.CreateAttachmentRequest): - request = gda_attachment.CreateAttachmentRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if attachment is not None: - request.attachment = attachment - if attachment_id is not None: - request.attachment_id = attachment_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_attachment] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - gda_attachment.Attachment, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_attachment(self, - request: Optional[Union[attachment.DeleteAttachmentRequest, 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes an attachment. The returned Operation will finish once - the attachments has been deleted. It will not have any Operation - metadata and will return a ``google.protobuf.Empty`` response. - - .. 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_delete_attachment(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteAttachmentRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_attachment(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteAttachmentRequest, dict]]): - The request object. The request to delete an attachment. - name (:class:`str`): - Required. The name of the attachment - to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, attachment.DeleteAttachmentRequest): - request = attachment.DeleteAttachmentRequest(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._client._transport._wrapped_methods[self._client._transport.delete_attachment] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # 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_async.AsyncRetry): 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 = self.transport._wrapped_methods[self._client._transport.get_operation] - - # 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),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` method. - retry (google.api_core.retry_async.AsyncRetry): 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self.transport._wrapped_methods[self._client._transport.get_location] - - # 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),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - async def list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` method. - retry (google.api_core.retry_async.AsyncRetry): 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self.transport._wrapped_methods[self._client._transport.list_locations] - - # 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),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - async def __aenter__(self) -> "ArtifactRegistryAsyncClient": - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "ArtifactRegistryAsyncClient", -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/client.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/client.py deleted file mode 100644 index 9bd2c8b340da..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/client.py +++ /dev/null @@ -1,6429 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 collections import OrderedDict -import os -import re -from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast -import warnings - -from google.cloud.artifactregistry_v1 import gapic_version as package_version - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.artifactregistry_v1.services.artifact_registry import pagers -from google.cloud.artifactregistry_v1.types import apt_artifact -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import attachment as gda_attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import file as gda_file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import package as gda_package -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 rule -from google.cloud.artifactregistry_v1.types import rule as gda_rule -from google.cloud.artifactregistry_v1.types import service -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 -from google.cloud.artifactregistry_v1.types import version as gda_version -from google.cloud.artifactregistry_v1.types import vpcsc_config -from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config -from google.cloud.artifactregistry_v1.types import yum_artifact -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 # type: ignore -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 -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import expr_pb2 # type: ignore -from .transports.base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import ArtifactRegistryGrpcTransport -from .transports.grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport -from .transports.rest import ArtifactRegistryRestTransport - - -class ArtifactRegistryClientMeta(type): - """Metaclass for the ArtifactRegistry client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - _transport_registry = OrderedDict() # type: Dict[str, Type[ArtifactRegistryTransport]] - _transport_registry["grpc"] = ArtifactRegistryGrpcTransport - _transport_registry["grpc_asyncio"] = ArtifactRegistryGrpcAsyncIOTransport - _transport_registry["rest"] = ArtifactRegistryRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[ArtifactRegistryTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class ArtifactRegistryClient(metaclass=ArtifactRegistryClientMeta): - """The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = "artifactregistry.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - _DEFAULT_ENDPOINT_TEMPLATE = "artifactregistry.{UNIVERSE_DOMAIN}" - _DEFAULT_UNIVERSE = "googleapis.com" - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ArtifactRegistryClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ArtifactRegistryClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file( - filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> ArtifactRegistryTransport: - """Returns the transport used by the client instance. - - Returns: - ArtifactRegistryTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def apt_artifact_path(project: str,location: str,repository: str,apt_artifact: str,) -> str: - """Returns a fully-qualified apt_artifact string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/aptArtifacts/{apt_artifact}".format(project=project, location=location, repository=repository, apt_artifact=apt_artifact, ) - - @staticmethod - def parse_apt_artifact_path(path: str) -> Dict[str,str]: - """Parses a apt_artifact path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/aptArtifacts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def attachment_path(project: str,location: str,repository: str,attachment: str,) -> str: - """Returns a fully-qualified attachment string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/attachments/{attachment}".format(project=project, location=location, repository=repository, attachment=attachment, ) - - @staticmethod - def parse_attachment_path(path: str) -> Dict[str,str]: - """Parses a attachment path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/attachments/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def docker_image_path(project: str,location: str,repository: str,docker_image: str,) -> str: - """Returns a fully-qualified docker_image string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/dockerImages/{docker_image}".format(project=project, location=location, repository=repository, docker_image=docker_image, ) - - @staticmethod - def parse_docker_image_path(path: str) -> Dict[str,str]: - """Parses a docker_image path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/dockerImages/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def file_path(project: str,location: str,repository: str,file: str,) -> str: - """Returns a fully-qualified file string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/files/{file}".format(project=project, location=location, repository=repository, file=file, ) - - @staticmethod - def parse_file_path(path: str) -> Dict[str,str]: - """Parses a file path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/files/(?P.+?)$", path) - 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,) -> str: - """Returns a fully-qualified project_settings string.""" - return "projects/{project}/projectSettings".format(project=project, ) - - @staticmethod - def parse_project_settings_path(path: str) -> Dict[str,str]: - """Parses a project_settings path into its component segments.""" - 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,location: str,repository: str,) -> str: - """Returns a fully-qualified repository string.""" - return "projects/{project}/locations/{location}/repositories/{repository}".format(project=project, location=location, repository=repository, ) - - @staticmethod - def parse_repository_path(path: str) -> Dict[str,str]: - """Parses a repository path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def rule_path(project: str,location: str,repository: str,rule: str,) -> str: - """Returns a fully-qualified rule string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/rules/{rule}".format(project=project, location=location, repository=repository, rule=rule, ) - - @staticmethod - def parse_rule_path(path: str) -> Dict[str,str]: - """Parses a rule path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/rules/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def secret_version_path(project: str,secret: str,secret_version: str,) -> str: - """Returns a fully-qualified secret_version string.""" - return "projects/{project}/secrets/{secret}/versions/{secret_version}".format(project=project, secret=secret, secret_version=secret_version, ) - - @staticmethod - def parse_secret_version_path(path: str) -> Dict[str,str]: - """Parses a secret_version path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/secrets/(?P.+?)/versions/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def tag_path(project: str,location: str,repository: str,package: str,tag: str,) -> str: - """Returns a fully-qualified tag string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag}".format(project=project, location=location, repository=repository, package=package, tag=tag, ) - - @staticmethod - def parse_tag_path(path: str) -> Dict[str,str]: - """Parses a tag path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/packages/(?P.+?)/tags/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def version_path(project: str,location: str,repository: str,package: str,version: str,) -> str: - """Returns a fully-qualified version string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/versions/{version}".format(project=project, location=location, repository=repository, package=package, version=version, ) - - @staticmethod - def parse_version_path(path: str) -> Dict[str,str]: - """Parses a version path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/packages/(?P.+?)/versions/(?P.+?)$", path) - 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,location: str,repository: str,yum_artifact: str,) -> str: - """Returns a fully-qualified yum_artifact string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/yumArtifacts/{yum_artifact}".format(project=project, location=location, repository=repository, yum_artifact=yum_artifact, ) - - @staticmethod - def parse_yum_artifact_path(path: str) -> Dict[str,str]: - """Parses a yum_artifact path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/yumArtifacts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str, ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str, ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str, ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path(project: str, location: str, ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format(project=project, location=location, ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): - """Deprecated. Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - - warnings.warn("get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.", - DeprecationWarning) - if client_options is None: - client_options = client_options_lib.ClientOptions() - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_client_cert not in ("true", "false"): - raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") - - # Figure out the client cert source to use. - client_cert_source = None - if use_client_cert == "true": - if client_options.client_cert_source: - client_cert_source = client_options.client_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): - api_endpoint = cls.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = cls.DEFAULT_ENDPOINT - - return api_endpoint, client_cert_source - - @staticmethod - def _read_environment_variables(): - """Returns the environment variables used by the client. - - Returns: - Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, - GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. - - Raises: - ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not - any of ["true", "false"]. - google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT - is not any of ["auto", "never", "always"]. - """ - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false").lower() - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() - universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") - if use_client_cert not in ("true", "false"): - raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") - return use_client_cert == "true", use_mtls_endpoint, universe_domain_env - - @staticmethod - def _get_client_cert_source(provided_cert_source, use_cert_flag): - """Return the client cert source to be used by the client. - - Args: - provided_cert_source (bytes): The client certificate source provided. - use_cert_flag (bool): A flag indicating whether to use the client certificate. - - Returns: - bytes or None: The client cert source to be used by the client. - """ - client_cert_source = None - if use_cert_flag: - if provided_cert_source: - client_cert_source = provided_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - return client_cert_source - - @staticmethod - def _get_api_endpoint(api_override, client_cert_source, universe_domain, use_mtls_endpoint): - """Return the API endpoint used by the client. - - Args: - api_override (str): The API endpoint override. If specified, this is always - the return value of this function and the other arguments are not used. - client_cert_source (bytes): The client certificate source used by the client. - universe_domain (str): The universe domain used by the client. - use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters. - Possible values are "always", "auto", or "never". - - Returns: - str: The API endpoint to be used by the client. - """ - if api_override is not None: - api_endpoint = api_override - elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): - _default_universe = ArtifactRegistryClient._DEFAULT_UNIVERSE - if universe_domain != _default_universe: - raise MutualTLSChannelError(f"mTLS is not supported in any universe other than {_default_universe}.") - api_endpoint = ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=universe_domain) - return api_endpoint - - @staticmethod - def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str: - """Return the universe domain used by the client. - - Args: - client_universe_domain (Optional[str]): The universe domain configured via the client options. - universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable. - - Returns: - str: The universe domain to be used by the client. - - Raises: - ValueError: If the universe domain is an empty string. - """ - universe_domain = ArtifactRegistryClient._DEFAULT_UNIVERSE - if client_universe_domain is not None: - universe_domain = client_universe_domain - elif universe_domain_env is not None: - universe_domain = universe_domain_env - if len(universe_domain.strip()) == 0: - raise ValueError("Universe Domain cannot be an empty string.") - return universe_domain - - @staticmethod - def _compare_universes(client_universe: str, - credentials: ga_credentials.Credentials) -> bool: - """Returns True iff the universe domains used by the client and credentials match. - - Args: - client_universe (str): The universe domain configured via the client options. - credentials (ga_credentials.Credentials): The credentials being used in the client. - - Returns: - bool: True iff client_universe matches the universe in credentials. - - Raises: - ValueError: when client_universe does not match the universe in credentials. - """ - - default_universe = ArtifactRegistryClient._DEFAULT_UNIVERSE - credentials_universe = getattr(credentials, "universe_domain", default_universe) - - if client_universe != credentials_universe: - raise ValueError("The configured universe domain " - f"({client_universe}) does not match the universe domain " - f"found in the credentials ({credentials_universe}). " - "If you haven't configured the universe domain explicitly, " - f"`{default_universe}` is the default.") - return True - - def _validate_universe_domain(self): - """Validates client's and credentials' universe domains are consistent. - - Returns: - bool: True iff the configured universe domain is valid. - - Raises: - ValueError: If the configured universe domain is not valid. - """ - self._is_universe_domain_valid = (self._is_universe_domain_valid or - ArtifactRegistryClient._compare_universes(self.universe_domain, self.transport._credentials)) - return self._is_universe_domain_valid - - @property - def api_endpoint(self): - """Return the API endpoint used by the client instance. - - Returns: - str: The API endpoint used by the client instance. - """ - return self._api_endpoint - - @property - def universe_domain(self) -> str: - """Return the universe domain used by the client instance. - - Returns: - str: The universe domain used by the client instance. - """ - return self._universe_domain - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, ArtifactRegistryTransport, Callable[..., ArtifactRegistryTransport]]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the artifact registry client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Optional[Union[str,ArtifactRegistryTransport,Callable[..., ArtifactRegistryTransport]]]): - The transport to use, or a Callable that constructs and returns a new transport. - If a Callable is given, it will be called with the same set of initialization - arguments as used in the ArtifactRegistryTransport constructor. - If set to None, a transport is chosen automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): - Custom options for the client. - - 1. The ``api_endpoint`` property can be used to override the - default endpoint provided by the client when ``transport`` is - not explicitly provided. Only if this property is not set and - ``transport`` was not explicitly provided, the endpoint is - determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment - variable, which have one of the following values: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto-switch to the - default mTLS endpoint if client certificate is present; this is - the default value). - - 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide a client certificate for mTLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - 3. The ``universe_domain`` property can be used to override the - default "googleapis.com" universe. Note that the ``api_endpoint`` - property still takes precedence; and ``universe_domain`` is - currently not supported for mTLS. - - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client_options = client_options - if isinstance(self._client_options, dict): - self._client_options = client_options_lib.from_dict(self._client_options) - if self._client_options is None: - self._client_options = client_options_lib.ClientOptions() - self._client_options = cast(client_options_lib.ClientOptions, self._client_options) - - universe_domain_opt = getattr(self._client_options, 'universe_domain', None) - - self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = ArtifactRegistryClient._read_environment_variables() - self._client_cert_source = ArtifactRegistryClient._get_client_cert_source(self._client_options.client_cert_source, self._use_client_cert) - self._universe_domain = ArtifactRegistryClient._get_universe_domain(universe_domain_opt, self._universe_domain_env) - self._api_endpoint = None # updated below, depending on `transport` - - # Initialize the universe domain validation. - self._is_universe_domain_valid = False - - api_key_value = getattr(self._client_options, "api_key", None) - if api_key_value and credentials: - raise ValueError("client_options.api_key and credentials are mutually exclusive") - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - transport_provided = isinstance(transport, ArtifactRegistryTransport) - if transport_provided: - # transport is a ArtifactRegistryTransport instance. - if credentials or self._client_options.credentials_file or api_key_value: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if self._client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = cast(ArtifactRegistryTransport, transport) - self._api_endpoint = self._transport.host - - self._api_endpoint = (self._api_endpoint or - ArtifactRegistryClient._get_api_endpoint( - self._client_options.api_endpoint, - self._client_cert_source, - self._universe_domain, - self._use_mtls_endpoint)) - - if not transport_provided: - import google.auth._default # type: ignore - - if api_key_value and hasattr(google.auth._default, "get_api_key_credentials"): - credentials = google.auth._default.get_api_key_credentials(api_key_value) - - transport_init: Union[Type[ArtifactRegistryTransport], Callable[..., ArtifactRegistryTransport]] = ( - ArtifactRegistryClient.get_transport_class(transport) - if isinstance(transport, str) or transport is None - else cast(Callable[..., ArtifactRegistryTransport], transport) - ) - # initialize with the provided callable or the passed in class - self._transport = transport_init( - credentials=credentials, - credentials_file=self._client_options.credentials_file, - host=self._api_endpoint, - scopes=self._client_options.scopes, - client_cert_source_for_mtls=self._client_cert_source, - quota_project_id=self._client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - api_audience=self._client_options.api_audience, - ) - - def list_docker_images(self, - request: Optional[Union[artifact.ListDockerImagesRequest, 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.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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - retry=retry, - timeout=timeout, - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - retry=retry, - timeout=timeout, - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - retry=retry, - timeout=timeout, - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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 - - # 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) - - Args: - 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 python 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.ListPythonPackagesPager: - The response from listing python - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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: - 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_python_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListPythonPackagesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_python_package(self, - 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.PythonPackage: - r"""Gets a python 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_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) - - Args: - 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 python - 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.PythonPackage: - PythonPackage represents a python - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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: - 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_python_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def import_apt_artifacts(self, - request: Optional[Union[apt_artifact.ImportAptArtifactsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Imports Apt artifacts. The returned Operation will - complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - .. 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_import_apt_artifacts(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ImportAptArtifactsRequest( - ) - - # Make the request - operation = client.import_apt_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest, dict]): - The request object. The request to import new apt - artifacts. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1.types.ImportAptArtifactsResponse` - The response message from importing APT artifacts. - - """ - # Create or coerce a protobuf request object. - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, apt_artifact.ImportAptArtifactsRequest): - request = apt_artifact.ImportAptArtifactsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.import_apt_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - apt_artifact.ImportAptArtifactsResponse, - metadata_type=apt_artifact.ImportAptArtifactsMetadata, - ) - - # Done; return the response. - return response - - def import_yum_artifacts(self, - request: Optional[Union[yum_artifact.ImportYumArtifactsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Imports Yum (RPM) artifacts. The returned Operation - will complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - .. 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_import_yum_artifacts(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ImportYumArtifactsRequest( - ) - - # Make the request - operation = client.import_yum_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest, dict]): - The request object. The request to import new yum - artifacts. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1.types.ImportYumArtifactsResponse` - The response message from importing YUM artifacts. - - """ - # Create or coerce a protobuf request object. - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, yum_artifact.ImportYumArtifactsRequest): - request = yum_artifact.ImportYumArtifactsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.import_yum_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - yum_artifact.ImportYumArtifactsResponse, - metadata_type=yum_artifact.ImportYumArtifactsMetadata, - ) - - # Done; return the response. - return response - - def list_repositories(self, - request: Optional[Union[repository.ListRepositoriesRequest, 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.ListRepositoriesPager: - r"""Lists repositories. - - .. 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_repositories(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListRepositoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_repositories(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ListRepositoriesRequest, dict]): - The request object. The request to list repositories. - parent (str): - Required. The name of the parent - resource whose repositories 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.ListRepositoriesPager: - The response from listing - repositories. - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.ListRepositoriesRequest): - request = repository.ListRepositoriesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_repositories] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListRepositoriesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_repository(self, - request: Optional[Union[repository.GetRepositoryRequest, 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]] = (), - ) -> repository.Repository: - r"""Gets a repository. - - .. 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_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetRepositoryRequest( - name="name_value", - ) - - # Make the request - response = client.get_repository(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.GetRepositoryRequest, dict]): - The request object. The request to retrieve a repository. - name (str): - Required. The name of the repository - to retrieve. - - 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.Repository: - A Repository for storing artifacts - with a specific format. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.GetRepositoryRequest): - request = repository.GetRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_repository(self, - request: Optional[Union[gda_repository.CreateRepositoryRequest, dict]] = None, - *, - parent: Optional[str] = None, - repository: Optional[gda_repository.Repository] = None, - repository_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a repository. The returned Operation will - finish once the repository has been created. Its - response will be the created Repository. - - .. 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_create_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateRepositoryRequest( - parent="parent_value", - repository_id="repository_id_value", - ) - - # Make the request - operation = client.create_repository(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.CreateRepositoryRequest, dict]): - The request object. The request to create a new - repository. - parent (str): - Required. The name of the parent - resource where the repository will be - created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - repository (google.cloud.artifactregistry_v1.types.Repository): - Required. The repository to be - created. - - This corresponds to the ``repository`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - repository_id (str): - Required. The repository id to use - for this repository. - - This corresponds to the ``repository_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1.types.Repository` - A Repository for storing artifacts with a specific - format. - - """ - # 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, repository, repository_id]) - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_repository.CreateRepositoryRequest): - request = gda_repository.CreateRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if repository is not None: - request.repository = repository - if repository_id is not None: - request.repository_id = repository_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - gda_repository.Repository, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_repository(self, - request: Optional[Union[gda_repository.UpdateRepositoryRequest, dict]] = None, - *, - repository: Optional[gda_repository.Repository] = 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_repository.Repository: - r"""Updates a repository. - - .. 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_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateRepositoryRequest( - ) - - # Make the request - response = client.update_repository(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.UpdateRepositoryRequest, dict]): - The request object. The request to update a repository. - repository (google.cloud.artifactregistry_v1.types.Repository): - The repository that replaces the - resource on the server. - - This corresponds to the ``repository`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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.Repository: - A Repository for storing artifacts - with a specific format. - - """ - # 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([repository, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_repository.UpdateRepositoryRequest): - request = gda_repository.UpdateRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if repository is not None: - request.repository = repository - if update_mask is not None: - 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_repository] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("repository.name", request.repository.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_repository(self, - request: Optional[Union[repository.DeleteRepositoryRequest, 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]] = (), - ) -> operation.Operation: - r"""Deletes a repository and all of its contents. The - returned Operation will finish once the repository has - been deleted. It will not have any Operation metadata - and will return a google.protobuf.Empty response. - - .. 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_delete_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteRepositoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_repository(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.DeleteRepositoryRequest, dict]): - The request object. The request to delete a repository. - name (str): - Required. The name of the repository - to delete. - - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.DeleteRepositoryRequest): - request = repository.DeleteRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_packages(self, - request: Optional[Union[package.ListPackagesRequest, 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.ListPackagesPager: - r"""Lists 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_packages(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListPackagesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_packages(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ListPackagesRequest, dict]): - The request object. The request to list packages. - parent (str): - Required. The name of the parent - resource whose 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.ListPackagesPager: - The response from listing 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.ListPackagesRequest): - request = package.ListPackagesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListPackagesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_package(self, - request: Optional[Union[package.GetPackageRequest, 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]] = (), - ) -> package.Package: - r"""Gets a 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_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetPackageRequest( - name="name_value", - ) - - # Make the request - response = client.get_package(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.GetPackageRequest, dict]): - The request object. The request to retrieve a package. - name (str): - Required. The name of the package to - retrieve. - - 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.Package: - Packages are named collections of - versions. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.GetPackageRequest): - request = package.GetPackageRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_package(self, - request: Optional[Union[package.DeletePackageRequest, 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]] = (), - ) -> operation.Operation: - r"""Deletes a package and all of its versions and tags. - The returned operation will complete once the package - has been deleted. - - .. 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_delete_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeletePackageRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_package(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.DeletePackageRequest, dict]): - The request object. The request to delete a package. - name (str): - Required. The name of the package to - delete. - - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.DeletePackageRequest): - request = package.DeletePackageRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_versions(self, - request: Optional[Union[version.ListVersionsRequest, 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.ListVersionsPager: - r"""Lists versions. - - .. 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_versions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListVersionsRequest( - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ListVersionsRequest, dict]): - The request object. The request to list versions. - parent (str): - The name of the parent resource whose - versions 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.ListVersionsPager: - The response from listing versions. - - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.ListVersionsRequest): - request = version.ListVersionsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_versions] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListVersionsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_version(self, - request: Optional[Union[version.GetVersionRequest, 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]] = (), - ) -> version.Version: - r"""Gets a version - - .. 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_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetVersionRequest( - ) - - # Make the request - response = client.get_version(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.GetVersionRequest, dict]): - The request object. The request to retrieve a version. - name (str): - The name of the version to retrieve. - 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.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.GetVersionRequest): - request = version.GetVersionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_version] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_version(self, - request: Optional[Union[version.DeleteVersionRequest, 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]] = (), - ) -> operation.Operation: - r"""Deletes a version and all of its content. The - returned operation will complete once the version has - been deleted. - - .. 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_delete_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteVersionRequest( - ) - - # Make the request - operation = client.delete_version(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.DeleteVersionRequest, dict]): - The request object. The request to delete a version. - name (str): - The name of the version to delete. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.DeleteVersionRequest): - request = version.DeleteVersionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_version] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def batch_delete_versions(self, - request: Optional[Union[version.BatchDeleteVersionsRequest, dict]] = None, - *, - parent: Optional[str] = None, - names: Optional[MutableSequence[str]] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Deletes multiple versions across a repository. The - returned operation will complete once the versions have - been deleted. - - .. 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_batch_delete_versions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.BatchDeleteVersionsRequest( - names=['names_value1', 'names_value2'], - ) - - # Make the request - operation = client.batch_delete_versions(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.BatchDeleteVersionsRequest, dict]): - The request object. The request to delete multiple - versions across a repository. - parent (str): - The name of the repository holding - all requested versions. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - names (MutableSequence[str]): - Required. The names of the versions - to delete. A maximum of 10000 versions - can be deleted in a batch. - - This corresponds to the ``names`` 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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, names]) - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.BatchDeleteVersionsRequest): - request = version.BatchDeleteVersionsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if names is not None: - request.names = names - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.batch_delete_versions] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=version.BatchDeleteVersionsMetadata, - ) - - # Done; return the response. - return response - - def update_version(self, - request: Optional[Union[gda_version.UpdateVersionRequest, dict]] = None, - *, - version: Optional[gda_version.Version] = 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_version.Version: - r"""Updates a version. - - .. 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_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateVersionRequest( - ) - - # Make the request - response = client.update_version(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.UpdateVersionRequest, dict]): - The request object. The request to update a version. - version (google.cloud.artifactregistry_v1.types.Version): - Required. The Version that replaces - the resource on the server. - - This corresponds to the ``version`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - # 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([version, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_version.UpdateVersionRequest): - request = gda_version.UpdateVersionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if version is not None: - request.version = version - 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_version] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("version.name", request.version.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_files(self, - request: Optional[Union[file.ListFilesRequest, 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.ListFilesPager: - r"""Lists files. - - .. 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_files(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListFilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_files(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ListFilesRequest, dict]): - The request object. The request to list files. - parent (str): - 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 - 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.ListFilesPager: - The response from listing files. - - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.ListFilesRequest): - request = file.ListFilesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_files] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListFilesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_file(self, - request: Optional[Union[file.GetFileRequest, 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]] = (), - ) -> file.File: - r"""Gets a file. - - .. 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_file(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetFileRequest( - name="name_value", - ) - - # Make the request - response = client.get_file(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.GetFileRequest, dict]): - The request object. The request to retrieve a file. - name (str): - 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. - 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.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.GetFileRequest): - request = file.GetFileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_file] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_file(self, - request: Optional[Union[file.DeleteFileRequest, 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]] = (), - ) -> operation.Operation: - r"""Deletes a file and all of its content. It is only - allowed on generic repositories. The returned operation - will complete once the file has been deleted. - - .. 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_delete_file(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteFileRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_file(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.DeleteFileRequest, dict]): - The request object. The request to delete a file. - name (str): - Required. The name of the file to - delete. - - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.DeleteFileRequest): - request = file.DeleteFileRequest(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.delete_file] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_file(self, - request: Optional[Union[gda_file.UpdateFileRequest, dict]] = None, - *, - file: Optional[gda_file.File] = 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_file.File: - r"""Updates a file. - - .. 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_file(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateFileRequest( - ) - - # Make the request - response = client.update_file(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.UpdateFileRequest, dict]): - The request object. The request to update a file. - file (google.cloud.artifactregistry_v1.types.File): - Required. The File that replaces the - resource on the server. - - This corresponds to the ``file`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - # 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([file, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_file.UpdateFileRequest): - request = gda_file.UpdateFileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if file is not None: - request.file = file - 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_file] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("file.name", request.file.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_tags(self, - request: Optional[Union[tag.ListTagsRequest, 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.ListTagsPager: - r"""Lists tags. - - .. 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_tags(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListTagsRequest( - ) - - # Make the request - page_result = client.list_tags(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ListTagsRequest, dict]): - The request object. The request to list tags. - parent (str): - The name of the parent package whose tags will be - listed. For example: - ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1``. - - 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.ListTagsPager: - The response from listing tags. - - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.ListTagsRequest): - request = tag.ListTagsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_tags] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListTagsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_tag(self, - request: Optional[Union[tag.GetTagRequest, 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]] = (), - ) -> tag.Tag: - r"""Gets a tag. - - .. 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_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetTagRequest( - ) - - # Make the request - response = client.get_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.GetTagRequest, dict]): - The request object. The request to retrieve a tag. - name (str): - The name of the tag to retrieve. - 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.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.GetTagRequest): - request = tag.GetTagRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_tag(self, - request: Optional[Union[gda_tag.CreateTagRequest, dict]] = None, - *, - parent: Optional[str] = None, - tag: Optional[gda_tag.Tag] = None, - tag_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gda_tag.Tag: - r"""Creates a tag. - - .. 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_create_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateTagRequest( - ) - - # Make the request - response = client.create_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.CreateTagRequest, dict]): - The request object. The request to create a new tag. - parent (str): - The name of the parent resource where - the tag will be created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag (google.cloud.artifactregistry_v1.types.Tag): - The tag to be created. - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag_id (str): - The tag id to use for this - repository. - - This corresponds to the ``tag_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.artifactregistry_v1.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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, tag, tag_id]) - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_tag.CreateTagRequest): - request = gda_tag.CreateTagRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if tag is not None: - request.tag = tag - if tag_id is not None: - request.tag_id = tag_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_tag(self, - request: Optional[Union[gda_tag.UpdateTagRequest, dict]] = None, - *, - tag: Optional[gda_tag.Tag] = 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_tag.Tag: - r"""Updates a tag. - - .. 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_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateTagRequest( - ) - - # Make the request - response = client.update_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.UpdateTagRequest, dict]): - The request object. The request to create or update a - tag. - tag (google.cloud.artifactregistry_v1.types.Tag): - The tag that replaces the resource on - the server. - - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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([tag, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_tag.UpdateTagRequest): - request = gda_tag.UpdateTagRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if tag is not None: - request.tag = tag - if update_mask is not None: - 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_tag] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("tag.name", request.tag.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_tag(self, - request: Optional[Union[tag.DeleteTagRequest, 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]] = (), - ) -> None: - r"""Deletes a tag. - - .. 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_delete_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteTagRequest( - ) - - # Make the request - client.delete_tag(request=request) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.DeleteTagRequest, dict]): - The request object. The request to delete a tag. - name (str): - The name of the tag to delete. - 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. - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.DeleteTagRequest): - request = tag.DeleteTagRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def create_rule(self, - request: Optional[Union[gda_rule.CreateRuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - rule: Optional[gda_rule.Rule] = None, - rule_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gda_rule.Rule: - r"""Creates a rule. - - .. 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_create_rule(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateRuleRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_rule(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.CreateRuleRequest, dict]): - The request object. The request to create a new rule. - parent (str): - Required. The name of the parent - resource where the rule will be created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - rule (google.cloud.artifactregistry_v1.types.Rule): - The rule to be created. - This corresponds to the ``rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - rule_id (str): - The rule id to use for this - repository. - - This corresponds to the ``rule_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.artifactregistry_v1.types.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - # 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, rule, rule_id]) - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_rule.CreateRuleRequest): - request = gda_rule.CreateRuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if rule is not None: - request.rule = rule - if rule_id is not None: - request.rule_id = rule_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_rule] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_rules(self, - request: Optional[Union[rule.ListRulesRequest, 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.ListRulesPager: - r"""Lists rules. - - .. 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_rules(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListRulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_rules(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ListRulesRequest, dict]): - The request object. The request to list rules. - parent (str): - Required. The name of the parent repository whose rules - will be listed. For example: - ``projects/p1/locations/us-central1/repositories/repo1``. - - 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.ListRulesPager: - The response from listing rules. - - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, rule.ListRulesRequest): - request = rule.ListRulesRequest(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_rules] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListRulesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_rule(self, - request: Optional[Union[rule.GetRuleRequest, 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]] = (), - ) -> rule.Rule: - r"""Gets a rule. - - .. 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_rule(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetRuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_rule(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.GetRuleRequest, dict]): - The request object. The request to retrieve a rule. - name (str): - Required. The name of the rule to - retrieve. - - 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.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, rule.GetRuleRequest): - request = rule.GetRuleRequest(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_rule] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_rule(self, - request: Optional[Union[gda_rule.UpdateRuleRequest, dict]] = None, - *, - rule: Optional[gda_rule.Rule] = 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_rule.Rule: - r"""Updates a rule. - - .. 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_rule(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateRuleRequest( - ) - - # Make the request - response = client.update_rule(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.UpdateRuleRequest, dict]): - The request object. The request to update a rule. - rule (google.cloud.artifactregistry_v1.types.Rule): - The rule that replaces the resource - on the server. - - This corresponds to the ``rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - # 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([rule, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_rule.UpdateRuleRequest): - request = gda_rule.UpdateRuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if rule is not None: - request.rule = rule - 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_rule] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("rule.name", request.rule.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_rule(self, - request: Optional[Union[rule.DeleteRuleRequest, 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]] = (), - ) -> None: - r"""Deletes a rule. - - .. 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_delete_rule(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteRuleRequest( - name="name_value", - ) - - # Make the request - client.delete_rule(request=request) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.DeleteRuleRequest, dict]): - The request object. The request to delete a rule. - name (str): - Required. The name of the rule to - delete. - - 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. - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, rule.DeleteRuleRequest): - request = rule.DeleteRuleRequest(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.delete_rule] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def set_iam_policy(self, - request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Updates the IAM policy for a given resource. - - .. 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 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - def sample_set_iam_policy(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = client.set_iam_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): - The request object. Request message for ``SetIamPolicy`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). - - """ - # Create or coerce a protobuf request object. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.SetIamPolicyRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.SetIamPolicyRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_iam_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_iam_policy(self, - request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Gets the IAM policy for a given resource. - - .. 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 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - def sample_get_iam_policy(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = client.get_iam_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): - The request object. Request message for ``GetIamPolicy`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). - - """ - # Create or coerce a protobuf request object. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.GetIamPolicyRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.GetIamPolicyRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_iam_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def test_iam_permissions(self, - request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Tests if the caller has a list of permissions on a - resource. - - .. 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 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - def sample_test_iam_permissions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], - ) - - # Make the request - response = client.test_iam_permissions(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): - The request object. Request message for ``TestIamPermissions`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: - Response message for TestIamPermissions method. - """ - # Create or coerce a protobuf request object. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.TestIamPermissionsRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.TestIamPermissionsRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_project_settings(self, - request: Optional[Union[settings.GetProjectSettingsRequest, 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]] = (), - ) -> settings.ProjectSettings: - r"""Retrieves the Settings 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_project_settings(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetProjectSettingsRequest( - name="name_value", - ) - - # Make the request - response = client.get_project_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest, dict]): - The request object. Gets the redirection status for a - project. - name (str): - Required. The name of the - projectSettings 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.ProjectSettings: - The Artifact Registry settings 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, settings.GetProjectSettingsRequest): - request = settings.GetProjectSettingsRequest(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_project_settings] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_project_settings(self, - request: Optional[Union[settings.UpdateProjectSettingsRequest, dict]] = None, - *, - project_settings: Optional[settings.ProjectSettings] = 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]] = (), - ) -> settings.ProjectSettings: - r"""Updates the Settings 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_project_settings(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateProjectSettingsRequest( - ) - - # Make the request - response = client.update_project_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest, dict]): - The request object. Sets the settings of the project. - project_settings (google.cloud.artifactregistry_v1.types.ProjectSettings): - The project settings. - This corresponds to the ``project_settings`` 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.ProjectSettings: - The Artifact Registry settings 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([project_settings, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, settings.UpdateProjectSettingsRequest): - request = settings.UpdateProjectSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if project_settings is not None: - request.project_settings = project_settings - 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_project_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("project_settings.name", request.project_settings.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_package(self, - request: Optional[Union[gda_package.UpdatePackageRequest, dict]] = None, - *, - package: Optional[gda_package.Package] = 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_package.Package: - r"""Updates a 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_update_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdatePackageRequest( - ) - - # Make the request - response = client.update_package(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.UpdatePackageRequest, dict]): - The request object. The request to update a package. - package (google.cloud.artifactregistry_v1.types.Package): - The package that replaces the - resource on the server. - - This corresponds to the ``package`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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.Package: - Packages are named collections of - versions. - - """ - # 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([package, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_package.UpdatePackageRequest): - request = gda_package.UpdatePackageRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if package is not None: - request.package = package - 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_package] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("package.name", request.package.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_attachments(self, - request: Optional[Union[attachment.ListAttachmentsRequest, 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.ListAttachmentsPager: - r"""Lists attachments. - - .. 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_attachments(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListAttachmentsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_attachments(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.ListAttachmentsRequest, dict]): - The request object. The request to list attachments. - parent (str): - Required. The name of the parent - resource whose attachments 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.ListAttachmentsPager: - The response from listing - attachments. - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, attachment.ListAttachmentsRequest): - request = attachment.ListAttachmentsRequest(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_attachments] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListAttachmentsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_attachment(self, - request: Optional[Union[attachment.GetAttachmentRequest, 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]] = (), - ) -> attachment.Attachment: - r"""Gets an attachment. - - .. 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_attachment(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetAttachmentRequest( - name="name_value", - ) - - # Make the request - response = client.get_attachment(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.GetAttachmentRequest, dict]): - The request object. The request to retrieve an - attachment. - name (str): - Required. The name of the attachment - to retrieve. - - 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.Attachment: - An Attachment refers to additional - metadata that can be attached to - artifacts in Artifact Registry. An - attachment consists of one or more - files. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, attachment.GetAttachmentRequest): - request = attachment.GetAttachmentRequest(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_attachment] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_attachment(self, - request: Optional[Union[gda_attachment.CreateAttachmentRequest, dict]] = None, - *, - parent: Optional[str] = None, - attachment: Optional[gda_attachment.Attachment] = None, - attachment_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates an attachment. The returned Operation will - finish once the attachment has been created. Its - response will be the created attachment. - - .. 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_create_attachment(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - attachment = artifactregistry_v1.Attachment() - attachment.target = "target_value" - attachment.files = ['files_value1', 'files_value2'] - - request = artifactregistry_v1.CreateAttachmentRequest( - parent="parent_value", - attachment_id="attachment_id_value", - attachment=attachment, - ) - - # Make the request - operation = client.create_attachment(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.CreateAttachmentRequest, dict]): - The request object. The request to create a new - attachment. - parent (str): - Required. The name of the parent - resource where the attachment will be - created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - attachment (google.cloud.artifactregistry_v1.types.Attachment): - Required. The attachment to be - created. - - This corresponds to the ``attachment`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - attachment_id (str): - Required. The attachment id to use - for this attachment. - - This corresponds to the ``attachment_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.artifactregistry_v1.types.Attachment` An Attachment refers to additional metadata that can be attached to - artifacts in Artifact Registry. An attachment - consists of one or more files. - - """ - # 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, attachment, attachment_id]) - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_attachment.CreateAttachmentRequest): - request = gda_attachment.CreateAttachmentRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if attachment is not None: - request.attachment = attachment - if attachment_id is not None: - request.attachment_id = attachment_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_attachment] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - gda_attachment.Attachment, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_attachment(self, - request: Optional[Union[attachment.DeleteAttachmentRequest, 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]] = (), - ) -> operation.Operation: - r"""Deletes an attachment. The returned Operation will finish once - the attachments has been deleted. It will not have any Operation - metadata and will return a ``google.protobuf.Empty`` response. - - .. 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_delete_attachment(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteAttachmentRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_attachment(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1.types.DeleteAttachmentRequest, dict]): - The request object. The request to delete an attachment. - name (str): - Required. The name of the attachment - to delete. - - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, attachment.DeleteAttachmentRequest): - request = attachment.DeleteAttachmentRequest(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.delete_attachment] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "ArtifactRegistryClient": - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - 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 = self._transport._wrapped_methods[self._transport.get_operation] - - # 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),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_location] - - # 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),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_locations] - - # 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),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "ArtifactRegistryClient", -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py deleted file mode 100644 index e6ea961c5bde..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py +++ /dev/null @@ -1,1519 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import retry_async as retries_async -from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator, Union -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] - OptionalAsyncRetry = Union[retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore - -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import repository -from google.cloud.artifactregistry_v1.types import rule -from google.cloud.artifactregistry_v1.types import tag -from google.cloud.artifactregistry_v1.types import version - - -class ListDockerImagesPager: - """A pager for iterating through ``list_docker_images`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListDockerImagesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``docker_images`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListDockerImages`` requests and continue to iterate - through the ``docker_images`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListDockerImagesResponse` - 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.ListDockerImagesResponse], - request: artifact.ListDockerImagesRequest, - response: artifact.ListDockerImagesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListDockerImagesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListDockerImagesResponse): - The initial response object. - 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. - """ - self._method = method - self._request = artifact.ListDockerImagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[artifact.ListDockerImagesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[artifact.DockerImage]: - for page in self.pages: - yield from page.docker_images - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListDockerImagesAsyncPager: - """A pager for iterating through ``list_docker_images`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListDockerImagesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``docker_images`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListDockerImages`` requests and continue to iterate - through the ``docker_images`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListDockerImagesResponse` - 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.ListDockerImagesResponse]], - request: artifact.ListDockerImagesRequest, - response: artifact.ListDockerImagesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListDockerImagesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListDockerImagesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = artifact.ListDockerImagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[artifact.ListDockerImagesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[artifact.DockerImage]: - async def async_generator(): - async for page in self.pages: - for response in page.docker_images: - yield response - - return async_generator() - - 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, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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. - 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. - """ - self._method = method - self._request = artifact.ListMavenArtifactsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - 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, retry=self._retry, timeout=self._timeout, 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, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = artifact.ListMavenArtifactsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - 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, retry=self._retry, timeout=self._timeout, 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, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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. - 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. - """ - self._method = method - self._request = artifact.ListNpmPackagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - 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, retry=self._retry, timeout=self._timeout, 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, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = artifact.ListNpmPackagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - 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, retry=self._retry, timeout=self._timeout, 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, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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. - 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. - """ - self._method = method - self._request = artifact.ListPythonPackagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - 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, retry=self._retry, timeout=self._timeout, 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, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = artifact.ListPythonPackagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - 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, retry=self._retry, timeout=self._timeout, 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. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListRepositoriesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``repositories`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListRepositories`` requests and continue to iterate - through the ``repositories`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListRepositoriesResponse` - 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[..., repository.ListRepositoriesResponse], - request: repository.ListRepositoriesRequest, - response: repository.ListRepositoriesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListRepositoriesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListRepositoriesResponse): - The initial response object. - 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. - """ - self._method = method - self._request = repository.ListRepositoriesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[repository.ListRepositoriesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[repository.Repository]: - for page in self.pages: - yield from page.repositories - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListRepositoriesAsyncPager: - """A pager for iterating through ``list_repositories`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListRepositoriesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``repositories`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListRepositories`` requests and continue to iterate - through the ``repositories`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListRepositoriesResponse` - 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[repository.ListRepositoriesResponse]], - request: repository.ListRepositoriesRequest, - response: repository.ListRepositoriesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListRepositoriesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListRepositoriesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = repository.ListRepositoriesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[repository.ListRepositoriesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[repository.Repository]: - async def async_generator(): - async for page in self.pages: - for response in page.repositories: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPackagesPager: - """A pager for iterating through ``list_packages`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListPackagesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``packages`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListPackages`` requests and continue to iterate - through the ``packages`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListPackagesResponse` - 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[..., package.ListPackagesResponse], - request: package.ListPackagesRequest, - response: package.ListPackagesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListPackagesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListPackagesResponse): - The initial response object. - 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. - """ - self._method = method - self._request = package.ListPackagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[package.ListPackagesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[package.Package]: - for page in self.pages: - yield from page.packages - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPackagesAsyncPager: - """A pager for iterating through ``list_packages`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListPackagesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``packages`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListPackages`` requests and continue to iterate - through the ``packages`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListPackagesResponse` - 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[package.ListPackagesResponse]], - request: package.ListPackagesRequest, - response: package.ListPackagesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListPackagesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListPackagesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = package.ListPackagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[package.ListPackagesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[package.Package]: - async def async_generator(): - async for page in self.pages: - for response in page.packages: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVersionsPager: - """A pager for iterating through ``list_versions`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListVersionsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``versions`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListVersions`` requests and continue to iterate - through the ``versions`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListVersionsResponse` - 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[..., version.ListVersionsResponse], - request: version.ListVersionsRequest, - response: version.ListVersionsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListVersionsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListVersionsResponse): - The initial response object. - 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. - """ - self._method = method - self._request = version.ListVersionsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[version.ListVersionsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[version.Version]: - for page in self.pages: - yield from page.versions - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVersionsAsyncPager: - """A pager for iterating through ``list_versions`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListVersionsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``versions`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListVersions`` requests and continue to iterate - through the ``versions`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListVersionsResponse` - 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[version.ListVersionsResponse]], - request: version.ListVersionsRequest, - response: version.ListVersionsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListVersionsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListVersionsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = version.ListVersionsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[version.ListVersionsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[version.Version]: - async def async_generator(): - async for page in self.pages: - for response in page.versions: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListFilesPager: - """A pager for iterating through ``list_files`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListFilesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``files`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListFiles`` requests and continue to iterate - through the ``files`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListFilesResponse` - 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[..., file.ListFilesResponse], - request: file.ListFilesRequest, - response: file.ListFilesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListFilesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListFilesResponse): - The initial response object. - 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. - """ - self._method = method - self._request = file.ListFilesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[file.ListFilesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[file.File]: - for page in self.pages: - yield from page.files - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListFilesAsyncPager: - """A pager for iterating through ``list_files`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListFilesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``files`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListFiles`` requests and continue to iterate - through the ``files`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListFilesResponse` - 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[file.ListFilesResponse]], - request: file.ListFilesRequest, - response: file.ListFilesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListFilesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListFilesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = file.ListFilesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[file.ListFilesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[file.File]: - async def async_generator(): - async for page in self.pages: - for response in page.files: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTagsPager: - """A pager for iterating through ``list_tags`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListTagsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``tags`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTags`` requests and continue to iterate - through the ``tags`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListTagsResponse` - 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[..., tag.ListTagsResponse], - request: tag.ListTagsRequest, - response: tag.ListTagsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListTagsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListTagsResponse): - The initial response object. - 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. - """ - self._method = method - self._request = tag.ListTagsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[tag.ListTagsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[tag.Tag]: - for page in self.pages: - yield from page.tags - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTagsAsyncPager: - """A pager for iterating through ``list_tags`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListTagsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``tags`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTags`` requests and continue to iterate - through the ``tags`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListTagsResponse` - 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[tag.ListTagsResponse]], - request: tag.ListTagsRequest, - response: tag.ListTagsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListTagsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListTagsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = tag.ListTagsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[tag.ListTagsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[tag.Tag]: - async def async_generator(): - async for page in self.pages: - for response in page.tags: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListRulesPager: - """A pager for iterating through ``list_rules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListRulesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``rules`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListRules`` requests and continue to iterate - through the ``rules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListRulesResponse` - 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[..., rule.ListRulesResponse], - request: rule.ListRulesRequest, - response: rule.ListRulesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListRulesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListRulesResponse): - The initial response object. - 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. - """ - self._method = method - self._request = rule.ListRulesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[rule.ListRulesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[rule.Rule]: - for page in self.pages: - yield from page.rules - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListRulesAsyncPager: - """A pager for iterating through ``list_rules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListRulesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``rules`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListRules`` requests and continue to iterate - through the ``rules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListRulesResponse` - 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[rule.ListRulesResponse]], - request: rule.ListRulesRequest, - response: rule.ListRulesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListRulesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListRulesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = rule.ListRulesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[rule.ListRulesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[rule.Rule]: - async def async_generator(): - async for page in self.pages: - for response in page.rules: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAttachmentsPager: - """A pager for iterating through ``list_attachments`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListAttachmentsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``attachments`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListAttachments`` requests and continue to iterate - through the ``attachments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListAttachmentsResponse` - 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[..., attachment.ListAttachmentsResponse], - request: attachment.ListAttachmentsRequest, - response: attachment.ListAttachmentsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListAttachmentsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListAttachmentsResponse): - The initial response object. - 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. - """ - self._method = method - self._request = attachment.ListAttachmentsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[attachment.ListAttachmentsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[attachment.Attachment]: - for page in self.pages: - yield from page.attachments - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListAttachmentsAsyncPager: - """A pager for iterating through ``list_attachments`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1.types.ListAttachmentsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``attachments`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListAttachments`` requests and continue to iterate - through the ``attachments`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1.types.ListAttachmentsResponse` - 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[attachment.ListAttachmentsResponse]], - request: attachment.ListAttachmentsRequest, - response: attachment.ListAttachmentsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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.ListAttachmentsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1.types.ListAttachmentsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = attachment.ListAttachmentsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[attachment.ListAttachmentsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[attachment.Attachment]: - async def async_generator(): - async for page in self.pages: - for response in page.attachments: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/README.rst b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/README.rst deleted file mode 100644 index d30fbe83290d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/README.rst +++ /dev/null @@ -1,9 +0,0 @@ - -transport inheritance structure -_______________________________ - -`ArtifactRegistryTransport` is the ABC for all transports. -- public child `ArtifactRegistryGrpcTransport` for sync gRPC transport (defined in `grpc.py`). -- public child `ArtifactRegistryGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). -- private child `_BaseArtifactRegistryRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). -- public child `ArtifactRegistryRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`). diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/__init__.py deleted file mode 100644 index 819525a6bc43..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 collections import OrderedDict -from typing import Dict, Type - -from .base import ArtifactRegistryTransport -from .grpc import ArtifactRegistryGrpcTransport -from .grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport -from .rest import ArtifactRegistryRestTransport -from .rest import ArtifactRegistryRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[ArtifactRegistryTransport]] -_transport_registry['grpc'] = ArtifactRegistryGrpcTransport -_transport_registry['grpc_asyncio'] = ArtifactRegistryGrpcAsyncIOTransport -_transport_registry['rest'] = ArtifactRegistryRestTransport - -__all__ = ( - 'ArtifactRegistryTransport', - 'ArtifactRegistryGrpcTransport', - 'ArtifactRegistryGrpcAsyncIOTransport', - 'ArtifactRegistryRestTransport', - 'ArtifactRegistryRestInterceptor', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py deleted file mode 100644 index 9f2533a01db7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py +++ /dev/null @@ -1,897 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union - -from google.cloud.artifactregistry_v1 import gapic_version as package_version - -import google.auth # type: ignore -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.artifactregistry_v1.types import apt_artifact -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import attachment as gda_attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import file as gda_file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import package as gda_package -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 rule -from google.cloud.artifactregistry_v1.types import rule as gda_rule -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 -from google.cloud.artifactregistry_v1.types import version as gda_version -from google.cloud.artifactregistry_v1.types import vpcsc_config -from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config -from google.cloud.artifactregistry_v1.types import yum_artifact -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 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class ArtifactRegistryTransport(abc.ABC): - """Abstract transport class for ArtifactRegistry.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ) - - DEFAULT_HOST: str = 'artifactregistry.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - """ - - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - - # Save the scopes. - self._scopes = scopes - if not hasattr(self, "_ignore_credentials"): - self._ignore_credentials: bool = False - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) - elif credentials is None and not self._ignore_credentials: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) - # Don't apply audience if the credentials file passed from user. - if hasattr(credentials, "with_gdch_audience"): - credentials = credentials.with_gdch_audience(api_audience if api_audience else host) - - # If the credentials are service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - @property - def host(self): - return self._host - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_docker_images: gapic_v1.method.wrap_method( - self.list_docker_images, - default_timeout=None, - client_info=client_info, - ), - self.get_docker_image: gapic_v1.method.wrap_method( - self.get_docker_image, - 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, - client_info=client_info, - ), - self.import_yum_artifacts: gapic_v1.method.wrap_method( - self.import_yum_artifacts, - default_timeout=None, - client_info=client_info, - ), - self.list_repositories: gapic_v1.method.wrap_method( - self.list_repositories, - default_timeout=None, - client_info=client_info, - ), - self.get_repository: gapic_v1.method.wrap_method( - self.get_repository, - default_timeout=None, - client_info=client_info, - ), - self.create_repository: gapic_v1.method.wrap_method( - self.create_repository, - default_timeout=None, - client_info=client_info, - ), - self.update_repository: gapic_v1.method.wrap_method( - self.update_repository, - default_timeout=None, - client_info=client_info, - ), - self.delete_repository: gapic_v1.method.wrap_method( - self.delete_repository, - default_timeout=None, - client_info=client_info, - ), - self.list_packages: gapic_v1.method.wrap_method( - self.list_packages, - default_timeout=None, - client_info=client_info, - ), - self.get_package: gapic_v1.method.wrap_method( - self.get_package, - default_timeout=None, - client_info=client_info, - ), - self.delete_package: gapic_v1.method.wrap_method( - self.delete_package, - default_timeout=None, - client_info=client_info, - ), - self.list_versions: gapic_v1.method.wrap_method( - self.list_versions, - default_timeout=None, - client_info=client_info, - ), - self.get_version: gapic_v1.method.wrap_method( - self.get_version, - default_timeout=None, - client_info=client_info, - ), - self.delete_version: gapic_v1.method.wrap_method( - self.delete_version, - default_timeout=None, - client_info=client_info, - ), - self.batch_delete_versions: gapic_v1.method.wrap_method( - self.batch_delete_versions, - default_timeout=None, - client_info=client_info, - ), - self.update_version: gapic_v1.method.wrap_method( - self.update_version, - default_timeout=None, - client_info=client_info, - ), - self.list_files: gapic_v1.method.wrap_method( - self.list_files, - default_timeout=None, - client_info=client_info, - ), - self.get_file: gapic_v1.method.wrap_method( - self.get_file, - default_timeout=None, - client_info=client_info, - ), - self.delete_file: gapic_v1.method.wrap_method( - self.delete_file, - default_timeout=None, - client_info=client_info, - ), - self.update_file: gapic_v1.method.wrap_method( - self.update_file, - default_timeout=None, - client_info=client_info, - ), - self.list_tags: gapic_v1.method.wrap_method( - self.list_tags, - default_timeout=None, - client_info=client_info, - ), - self.get_tag: gapic_v1.method.wrap_method( - self.get_tag, - default_timeout=None, - client_info=client_info, - ), - self.create_tag: gapic_v1.method.wrap_method( - self.create_tag, - default_timeout=None, - client_info=client_info, - ), - self.update_tag: gapic_v1.method.wrap_method( - self.update_tag, - default_timeout=None, - client_info=client_info, - ), - self.delete_tag: gapic_v1.method.wrap_method( - self.delete_tag, - default_timeout=None, - client_info=client_info, - ), - self.create_rule: gapic_v1.method.wrap_method( - self.create_rule, - default_timeout=None, - client_info=client_info, - ), - self.list_rules: gapic_v1.method.wrap_method( - self.list_rules, - default_timeout=None, - client_info=client_info, - ), - self.get_rule: gapic_v1.method.wrap_method( - self.get_rule, - default_timeout=None, - client_info=client_info, - ), - self.update_rule: gapic_v1.method.wrap_method( - self.update_rule, - default_timeout=None, - client_info=client_info, - ), - self.delete_rule: gapic_v1.method.wrap_method( - self.delete_rule, - default_timeout=None, - client_info=client_info, - ), - self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, - default_timeout=None, - client_info=client_info, - ), - self.get_iam_policy: gapic_v1.method.wrap_method( - self.get_iam_policy, - default_timeout=None, - client_info=client_info, - ), - self.test_iam_permissions: gapic_v1.method.wrap_method( - self.test_iam_permissions, - default_timeout=None, - client_info=client_info, - ), - self.get_project_settings: gapic_v1.method.wrap_method( - self.get_project_settings, - default_timeout=None, - client_info=client_info, - ), - self.update_project_settings: gapic_v1.method.wrap_method( - self.update_project_settings, - 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, - ), - self.update_package: gapic_v1.method.wrap_method( - self.update_package, - default_timeout=None, - client_info=client_info, - ), - self.list_attachments: gapic_v1.method.wrap_method( - self.list_attachments, - default_timeout=None, - client_info=client_info, - ), - self.get_attachment: gapic_v1.method.wrap_method( - self.get_attachment, - default_timeout=None, - client_info=client_info, - ), - self.create_attachment: gapic_v1.method.wrap_method( - self.create_attachment, - default_timeout=None, - client_info=client_info, - ), - self.delete_attachment: gapic_v1.method.wrap_method( - self.delete_attachment, - default_timeout=None, - client_info=client_info, - ), - self.get_location: gapic_v1.method.wrap_method( - self.get_location, - default_timeout=None, - client_info=client_info, - ), - self.list_locations: gapic_v1.method.wrap_method( - self.list_locations, - default_timeout=None, - client_info=client_info, - ), - self.get_operation: gapic_v1.method.wrap_method( - self.get_operation, - default_timeout=None, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def operations_client(self): - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def list_docker_images(self) -> Callable[ - [artifact.ListDockerImagesRequest], - Union[ - artifact.ListDockerImagesResponse, - Awaitable[artifact.ListDockerImagesResponse] - ]]: - raise NotImplementedError() - - @property - def get_docker_image(self) -> Callable[ - [artifact.GetDockerImageRequest], - Union[ - artifact.DockerImage, - Awaitable[artifact.DockerImage] - ]]: - 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) -> Callable[ - [apt_artifact.ImportAptArtifactsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def import_yum_artifacts(self) -> Callable[ - [yum_artifact.ImportYumArtifactsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_repositories(self) -> Callable[ - [repository.ListRepositoriesRequest], - Union[ - repository.ListRepositoriesResponse, - Awaitable[repository.ListRepositoriesResponse] - ]]: - raise NotImplementedError() - - @property - def get_repository(self) -> Callable[ - [repository.GetRepositoryRequest], - Union[ - repository.Repository, - Awaitable[repository.Repository] - ]]: - raise NotImplementedError() - - @property - def create_repository(self) -> Callable[ - [gda_repository.CreateRepositoryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_repository(self) -> Callable[ - [gda_repository.UpdateRepositoryRequest], - Union[ - gda_repository.Repository, - Awaitable[gda_repository.Repository] - ]]: - raise NotImplementedError() - - @property - def delete_repository(self) -> Callable[ - [repository.DeleteRepositoryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_packages(self) -> Callable[ - [package.ListPackagesRequest], - Union[ - package.ListPackagesResponse, - Awaitable[package.ListPackagesResponse] - ]]: - raise NotImplementedError() - - @property - def get_package(self) -> Callable[ - [package.GetPackageRequest], - Union[ - package.Package, - Awaitable[package.Package] - ]]: - raise NotImplementedError() - - @property - def delete_package(self) -> Callable[ - [package.DeletePackageRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - Union[ - version.ListVersionsResponse, - Awaitable[version.ListVersionsResponse] - ]]: - raise NotImplementedError() - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - Union[ - version.Version, - Awaitable[version.Version] - ]]: - raise NotImplementedError() - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def batch_delete_versions(self) -> Callable[ - [version.BatchDeleteVersionsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_version(self) -> Callable[ - [gda_version.UpdateVersionRequest], - Union[ - gda_version.Version, - Awaitable[gda_version.Version] - ]]: - raise NotImplementedError() - - @property - def list_files(self) -> Callable[ - [file.ListFilesRequest], - Union[ - file.ListFilesResponse, - Awaitable[file.ListFilesResponse] - ]]: - raise NotImplementedError() - - @property - def get_file(self) -> Callable[ - [file.GetFileRequest], - Union[ - file.File, - Awaitable[file.File] - ]]: - raise NotImplementedError() - - @property - def delete_file(self) -> Callable[ - [file.DeleteFileRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_file(self) -> Callable[ - [gda_file.UpdateFileRequest], - Union[ - gda_file.File, - Awaitable[gda_file.File] - ]]: - raise NotImplementedError() - - @property - def list_tags(self) -> Callable[ - [tag.ListTagsRequest], - Union[ - tag.ListTagsResponse, - Awaitable[tag.ListTagsResponse] - ]]: - raise NotImplementedError() - - @property - def get_tag(self) -> Callable[ - [tag.GetTagRequest], - Union[ - tag.Tag, - Awaitable[tag.Tag] - ]]: - raise NotImplementedError() - - @property - def create_tag(self) -> Callable[ - [gda_tag.CreateTagRequest], - Union[ - gda_tag.Tag, - Awaitable[gda_tag.Tag] - ]]: - raise NotImplementedError() - - @property - def update_tag(self) -> Callable[ - [gda_tag.UpdateTagRequest], - Union[ - gda_tag.Tag, - Awaitable[gda_tag.Tag] - ]]: - raise NotImplementedError() - - @property - def delete_tag(self) -> Callable[ - [tag.DeleteTagRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def create_rule(self) -> Callable[ - [gda_rule.CreateRuleRequest], - Union[ - gda_rule.Rule, - Awaitable[gda_rule.Rule] - ]]: - raise NotImplementedError() - - @property - def list_rules(self) -> Callable[ - [rule.ListRulesRequest], - Union[ - rule.ListRulesResponse, - Awaitable[rule.ListRulesResponse] - ]]: - raise NotImplementedError() - - @property - def get_rule(self) -> Callable[ - [rule.GetRuleRequest], - Union[ - rule.Rule, - Awaitable[rule.Rule] - ]]: - raise NotImplementedError() - - @property - def update_rule(self) -> Callable[ - [gda_rule.UpdateRuleRequest], - Union[ - gda_rule.Rule, - Awaitable[gda_rule.Rule] - ]]: - raise NotImplementedError() - - @property - def delete_rule(self) -> Callable[ - [rule.DeleteRuleRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def set_iam_policy(self) -> Callable[ - [iam_policy_pb2.SetIamPolicyRequest], - Union[ - policy_pb2.Policy, - Awaitable[policy_pb2.Policy] - ]]: - raise NotImplementedError() - - @property - def get_iam_policy(self) -> Callable[ - [iam_policy_pb2.GetIamPolicyRequest], - Union[ - policy_pb2.Policy, - Awaitable[policy_pb2.Policy] - ]]: - raise NotImplementedError() - - @property - def test_iam_permissions(self) -> Callable[ - [iam_policy_pb2.TestIamPermissionsRequest], - Union[ - iam_policy_pb2.TestIamPermissionsResponse, - Awaitable[iam_policy_pb2.TestIamPermissionsResponse] - ]]: - raise NotImplementedError() - - @property - def get_project_settings(self) -> Callable[ - [settings.GetProjectSettingsRequest], - Union[ - settings.ProjectSettings, - Awaitable[settings.ProjectSettings] - ]]: - raise NotImplementedError() - - @property - def update_project_settings(self) -> Callable[ - [settings.UpdateProjectSettingsRequest], - Union[ - settings.ProjectSettings, - Awaitable[settings.ProjectSettings] - ]]: - 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 update_package(self) -> Callable[ - [gda_package.UpdatePackageRequest], - Union[ - gda_package.Package, - Awaitable[gda_package.Package] - ]]: - raise NotImplementedError() - - @property - def list_attachments(self) -> Callable[ - [attachment.ListAttachmentsRequest], - Union[ - attachment.ListAttachmentsResponse, - Awaitable[attachment.ListAttachmentsResponse] - ]]: - raise NotImplementedError() - - @property - def get_attachment(self) -> Callable[ - [attachment.GetAttachmentRequest], - Union[ - attachment.Attachment, - Awaitable[attachment.Attachment] - ]]: - raise NotImplementedError() - - @property - def create_attachment(self) -> Callable[ - [gda_attachment.CreateAttachmentRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_attachment(self) -> Callable[ - [attachment.DeleteAttachmentRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - 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, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'ArtifactRegistryTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py deleted file mode 100644 index 5937fac9b316..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py +++ /dev/null @@ -1,1652 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.artifactregistry_v1.types import apt_artifact -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import attachment as gda_attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import file as gda_file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import package as gda_package -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 rule -from google.cloud.artifactregistry_v1.types import rule as gda_rule -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 -from google.cloud.artifactregistry_v1.types import version as gda_version -from google.cloud.artifactregistry_v1.types import vpcsc_config -from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config -from google.cloud.artifactregistry_v1.types import yum_artifact -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 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO - - -class ArtifactRegistryGrpcTransport(ArtifactRegistryTransport): - """gRPC backend transport for ArtifactRegistry. - - The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - _stubs: Dict[str, Callable] - - def __init__(self, *, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if a ``channel`` instance is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if a ``channel`` instance is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if a ``channel`` instance is provided. - channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): - A ``Channel`` instance through which to make calls, or a Callable - that constructs and returns one. If set to None, ``self.create_channel`` - is used to create the channel. If a Callable is given, it will be called - with the same arguments as used in ``self.create_channel``. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if a ``channel`` instance is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client: Optional[operations_v1.OperationsClient] = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if isinstance(channel, grpc.Channel): - # Ignore credentials if a channel was passed. - credentials = None - self._ignore_credentials = True - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - # initialize with the provided callable or the default channel - channel_init = channel or type(self).create_channel - self._grpc_channel = channel_init( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_docker_images(self) -> Callable[ - [artifact.ListDockerImagesRequest], - artifact.ListDockerImagesResponse]: - r"""Return a callable for the list docker images method over gRPC. - - Lists docker images. - - Returns: - Callable[[~.ListDockerImagesRequest], - ~.ListDockerImagesResponse]: - 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_docker_images' not in self._stubs: - self._stubs['list_docker_images'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListDockerImages', - request_serializer=artifact.ListDockerImagesRequest.serialize, - response_deserializer=artifact.ListDockerImagesResponse.deserialize, - ) - return self._stubs['list_docker_images'] - - @property - def get_docker_image(self) -> Callable[ - [artifact.GetDockerImageRequest], - artifact.DockerImage]: - r"""Return a callable for the get docker image method over gRPC. - - Gets a docker image. - - Returns: - Callable[[~.GetDockerImageRequest], - ~.DockerImage]: - 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_docker_image' not in self._stubs: - self._stubs['get_docker_image'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetDockerImage', - request_serializer=artifact.GetDockerImageRequest.serialize, - response_deserializer=artifact.DockerImage.deserialize, - ) - 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) -> Callable[ - [apt_artifact.ImportAptArtifactsRequest], - operations_pb2.Operation]: - r"""Return a callable for the import apt artifacts method over gRPC. - - Imports Apt artifacts. The returned Operation will - complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - Returns: - Callable[[~.ImportAptArtifactsRequest], - ~.Operation]: - 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 'import_apt_artifacts' not in self._stubs: - self._stubs['import_apt_artifacts'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ImportAptArtifacts', - request_serializer=apt_artifact.ImportAptArtifactsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_apt_artifacts'] - - @property - def import_yum_artifacts(self) -> Callable[ - [yum_artifact.ImportYumArtifactsRequest], - operations_pb2.Operation]: - r"""Return a callable for the import yum artifacts method over gRPC. - - Imports Yum (RPM) artifacts. The returned Operation - will complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - Returns: - Callable[[~.ImportYumArtifactsRequest], - ~.Operation]: - 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 'import_yum_artifacts' not in self._stubs: - self._stubs['import_yum_artifacts'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ImportYumArtifacts', - request_serializer=yum_artifact.ImportYumArtifactsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_yum_artifacts'] - - @property - def list_repositories(self) -> Callable[ - [repository.ListRepositoriesRequest], - repository.ListRepositoriesResponse]: - r"""Return a callable for the list repositories method over gRPC. - - Lists repositories. - - Returns: - Callable[[~.ListRepositoriesRequest], - ~.ListRepositoriesResponse]: - 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_repositories' not in self._stubs: - self._stubs['list_repositories'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRepositories', - request_serializer=repository.ListRepositoriesRequest.serialize, - response_deserializer=repository.ListRepositoriesResponse.deserialize, - ) - return self._stubs['list_repositories'] - - @property - def get_repository(self) -> Callable[ - [repository.GetRepositoryRequest], - repository.Repository]: - r"""Return a callable for the get repository method over gRPC. - - Gets a repository. - - Returns: - Callable[[~.GetRepositoryRequest], - ~.Repository]: - 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_repository' not in self._stubs: - self._stubs['get_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRepository', - request_serializer=repository.GetRepositoryRequest.serialize, - response_deserializer=repository.Repository.deserialize, - ) - return self._stubs['get_repository'] - - @property - def create_repository(self) -> Callable[ - [gda_repository.CreateRepositoryRequest], - operations_pb2.Operation]: - r"""Return a callable for the create repository method over gRPC. - - Creates a repository. The returned Operation will - finish once the repository has been created. Its - response will be the created Repository. - - Returns: - Callable[[~.CreateRepositoryRequest], - ~.Operation]: - 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 'create_repository' not in self._stubs: - self._stubs['create_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRepository', - request_serializer=gda_repository.CreateRepositoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_repository'] - - @property - def update_repository(self) -> Callable[ - [gda_repository.UpdateRepositoryRequest], - gda_repository.Repository]: - r"""Return a callable for the update repository method over gRPC. - - Updates a repository. - - Returns: - Callable[[~.UpdateRepositoryRequest], - ~.Repository]: - 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_repository' not in self._stubs: - self._stubs['update_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRepository', - request_serializer=gda_repository.UpdateRepositoryRequest.serialize, - response_deserializer=gda_repository.Repository.deserialize, - ) - return self._stubs['update_repository'] - - @property - def delete_repository(self) -> Callable[ - [repository.DeleteRepositoryRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete repository method over gRPC. - - Deletes a repository and all of its contents. The - returned Operation will finish once the repository has - been deleted. It will not have any Operation metadata - and will return a google.protobuf.Empty response. - - Returns: - Callable[[~.DeleteRepositoryRequest], - ~.Operation]: - 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 'delete_repository' not in self._stubs: - self._stubs['delete_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRepository', - request_serializer=repository.DeleteRepositoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_repository'] - - @property - def list_packages(self) -> Callable[ - [package.ListPackagesRequest], - package.ListPackagesResponse]: - r"""Return a callable for the list packages method over gRPC. - - Lists packages. - - Returns: - Callable[[~.ListPackagesRequest], - ~.ListPackagesResponse]: - 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_packages' not in self._stubs: - self._stubs['list_packages'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListPackages', - request_serializer=package.ListPackagesRequest.serialize, - response_deserializer=package.ListPackagesResponse.deserialize, - ) - return self._stubs['list_packages'] - - @property - def get_package(self) -> Callable[ - [package.GetPackageRequest], - package.Package]: - r"""Return a callable for the get package method over gRPC. - - Gets a package. - - Returns: - Callable[[~.GetPackageRequest], - ~.Package]: - 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_package' not in self._stubs: - self._stubs['get_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetPackage', - request_serializer=package.GetPackageRequest.serialize, - response_deserializer=package.Package.deserialize, - ) - return self._stubs['get_package'] - - @property - def delete_package(self) -> Callable[ - [package.DeletePackageRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete package method over gRPC. - - Deletes a package and all of its versions and tags. - The returned operation will complete once the package - has been deleted. - - Returns: - Callable[[~.DeletePackageRequest], - ~.Operation]: - 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 'delete_package' not in self._stubs: - self._stubs['delete_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeletePackage', - request_serializer=package.DeletePackageRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_package'] - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - version.ListVersionsResponse]: - r"""Return a callable for the list versions method over gRPC. - - Lists versions. - - Returns: - Callable[[~.ListVersionsRequest], - ~.ListVersionsResponse]: - 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_versions' not in self._stubs: - self._stubs['list_versions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListVersions', - request_serializer=version.ListVersionsRequest.serialize, - response_deserializer=version.ListVersionsResponse.deserialize, - ) - return self._stubs['list_versions'] - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - version.Version]: - r"""Return a callable for the get version method over gRPC. - - Gets a version - - Returns: - Callable[[~.GetVersionRequest], - ~.Version]: - 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_version' not in self._stubs: - self._stubs['get_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetVersion', - request_serializer=version.GetVersionRequest.serialize, - response_deserializer=version.Version.deserialize, - ) - return self._stubs['get_version'] - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete version method over gRPC. - - Deletes a version and all of its content. The - returned operation will complete once the version has - been deleted. - - Returns: - Callable[[~.DeleteVersionRequest], - ~.Operation]: - 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 'delete_version' not in self._stubs: - self._stubs['delete_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteVersion', - request_serializer=version.DeleteVersionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_version'] - - @property - def batch_delete_versions(self) -> Callable[ - [version.BatchDeleteVersionsRequest], - operations_pb2.Operation]: - r"""Return a callable for the batch delete versions method over gRPC. - - Deletes multiple versions across a repository. The - returned operation will complete once the versions have - been deleted. - - Returns: - Callable[[~.BatchDeleteVersionsRequest], - ~.Operation]: - 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 'batch_delete_versions' not in self._stubs: - self._stubs['batch_delete_versions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/BatchDeleteVersions', - request_serializer=version.BatchDeleteVersionsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_delete_versions'] - - @property - def update_version(self) -> Callable[ - [gda_version.UpdateVersionRequest], - gda_version.Version]: - r"""Return a callable for the update version method over gRPC. - - Updates a version. - - Returns: - Callable[[~.UpdateVersionRequest], - ~.Version]: - 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_version' not in self._stubs: - self._stubs['update_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVersion', - request_serializer=gda_version.UpdateVersionRequest.serialize, - response_deserializer=gda_version.Version.deserialize, - ) - return self._stubs['update_version'] - - @property - def list_files(self) -> Callable[ - [file.ListFilesRequest], - file.ListFilesResponse]: - r"""Return a callable for the list files method over gRPC. - - Lists files. - - Returns: - Callable[[~.ListFilesRequest], - ~.ListFilesResponse]: - 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_files' not in self._stubs: - self._stubs['list_files'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListFiles', - request_serializer=file.ListFilesRequest.serialize, - response_deserializer=file.ListFilesResponse.deserialize, - ) - return self._stubs['list_files'] - - @property - def get_file(self) -> Callable[ - [file.GetFileRequest], - file.File]: - r"""Return a callable for the get file method over gRPC. - - Gets a file. - - Returns: - Callable[[~.GetFileRequest], - ~.File]: - 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_file' not in self._stubs: - self._stubs['get_file'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetFile', - request_serializer=file.GetFileRequest.serialize, - response_deserializer=file.File.deserialize, - ) - return self._stubs['get_file'] - - @property - def delete_file(self) -> Callable[ - [file.DeleteFileRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete file method over gRPC. - - Deletes a file and all of its content. It is only - allowed on generic repositories. The returned operation - will complete once the file has been deleted. - - Returns: - Callable[[~.DeleteFileRequest], - ~.Operation]: - 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 'delete_file' not in self._stubs: - self._stubs['delete_file'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteFile', - request_serializer=file.DeleteFileRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_file'] - - @property - def update_file(self) -> Callable[ - [gda_file.UpdateFileRequest], - gda_file.File]: - r"""Return a callable for the update file method over gRPC. - - Updates a file. - - Returns: - Callable[[~.UpdateFileRequest], - ~.File]: - 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_file' not in self._stubs: - self._stubs['update_file'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateFile', - request_serializer=gda_file.UpdateFileRequest.serialize, - response_deserializer=gda_file.File.deserialize, - ) - return self._stubs['update_file'] - - @property - def list_tags(self) -> Callable[ - [tag.ListTagsRequest], - tag.ListTagsResponse]: - r"""Return a callable for the list tags method over gRPC. - - Lists tags. - - Returns: - Callable[[~.ListTagsRequest], - ~.ListTagsResponse]: - 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_tags' not in self._stubs: - self._stubs['list_tags'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListTags', - request_serializer=tag.ListTagsRequest.serialize, - response_deserializer=tag.ListTagsResponse.deserialize, - ) - return self._stubs['list_tags'] - - @property - def get_tag(self) -> Callable[ - [tag.GetTagRequest], - tag.Tag]: - r"""Return a callable for the get tag method over gRPC. - - Gets a tag. - - Returns: - Callable[[~.GetTagRequest], - ~.Tag]: - 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_tag' not in self._stubs: - self._stubs['get_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetTag', - request_serializer=tag.GetTagRequest.serialize, - response_deserializer=tag.Tag.deserialize, - ) - return self._stubs['get_tag'] - - @property - def create_tag(self) -> Callable[ - [gda_tag.CreateTagRequest], - gda_tag.Tag]: - r"""Return a callable for the create tag method over gRPC. - - Creates a tag. - - Returns: - Callable[[~.CreateTagRequest], - ~.Tag]: - 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 'create_tag' not in self._stubs: - self._stubs['create_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateTag', - request_serializer=gda_tag.CreateTagRequest.serialize, - response_deserializer=gda_tag.Tag.deserialize, - ) - return self._stubs['create_tag'] - - @property - def update_tag(self) -> Callable[ - [gda_tag.UpdateTagRequest], - gda_tag.Tag]: - r"""Return a callable for the update tag method over gRPC. - - Updates a tag. - - Returns: - Callable[[~.UpdateTagRequest], - ~.Tag]: - 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_tag' not in self._stubs: - self._stubs['update_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateTag', - request_serializer=gda_tag.UpdateTagRequest.serialize, - response_deserializer=gda_tag.Tag.deserialize, - ) - return self._stubs['update_tag'] - - @property - def delete_tag(self) -> Callable[ - [tag.DeleteTagRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete tag method over gRPC. - - Deletes a tag. - - Returns: - Callable[[~.DeleteTagRequest], - ~.Empty]: - 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 'delete_tag' not in self._stubs: - self._stubs['delete_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteTag', - request_serializer=tag.DeleteTagRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_tag'] - - @property - def create_rule(self) -> Callable[ - [gda_rule.CreateRuleRequest], - gda_rule.Rule]: - r"""Return a callable for the create rule method over gRPC. - - Creates a rule. - - Returns: - Callable[[~.CreateRuleRequest], - ~.Rule]: - 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 'create_rule' not in self._stubs: - self._stubs['create_rule'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRule', - request_serializer=gda_rule.CreateRuleRequest.serialize, - response_deserializer=gda_rule.Rule.deserialize, - ) - return self._stubs['create_rule'] - - @property - def list_rules(self) -> Callable[ - [rule.ListRulesRequest], - rule.ListRulesResponse]: - r"""Return a callable for the list rules method over gRPC. - - Lists rules. - - Returns: - Callable[[~.ListRulesRequest], - ~.ListRulesResponse]: - 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_rules' not in self._stubs: - self._stubs['list_rules'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRules', - request_serializer=rule.ListRulesRequest.serialize, - response_deserializer=rule.ListRulesResponse.deserialize, - ) - return self._stubs['list_rules'] - - @property - def get_rule(self) -> Callable[ - [rule.GetRuleRequest], - rule.Rule]: - r"""Return a callable for the get rule method over gRPC. - - Gets a rule. - - Returns: - Callable[[~.GetRuleRequest], - ~.Rule]: - 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_rule' not in self._stubs: - self._stubs['get_rule'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRule', - request_serializer=rule.GetRuleRequest.serialize, - response_deserializer=rule.Rule.deserialize, - ) - return self._stubs['get_rule'] - - @property - def update_rule(self) -> Callable[ - [gda_rule.UpdateRuleRequest], - gda_rule.Rule]: - r"""Return a callable for the update rule method over gRPC. - - Updates a rule. - - Returns: - Callable[[~.UpdateRuleRequest], - ~.Rule]: - 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_rule' not in self._stubs: - self._stubs['update_rule'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRule', - request_serializer=gda_rule.UpdateRuleRequest.serialize, - response_deserializer=gda_rule.Rule.deserialize, - ) - return self._stubs['update_rule'] - - @property - def delete_rule(self) -> Callable[ - [rule.DeleteRuleRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete rule method over gRPC. - - Deletes a rule. - - Returns: - Callable[[~.DeleteRuleRequest], - ~.Empty]: - 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 'delete_rule' not in self._stubs: - self._stubs['delete_rule'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRule', - request_serializer=rule.DeleteRuleRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_rule'] - - @property - def set_iam_policy(self) -> Callable[ - [iam_policy_pb2.SetIamPolicyRequest], - policy_pb2.Policy]: - r"""Return a callable for the set iam policy method over gRPC. - - Updates the IAM policy for a given resource. - - Returns: - Callable[[~.SetIamPolicyRequest], - ~.Policy]: - 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 'set_iam_policy' not in self._stubs: - self._stubs['set_iam_policy'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/SetIamPolicy', - request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, - response_deserializer=policy_pb2.Policy.FromString, - ) - return self._stubs['set_iam_policy'] - - @property - def get_iam_policy(self) -> Callable[ - [iam_policy_pb2.GetIamPolicyRequest], - policy_pb2.Policy]: - r"""Return a callable for the get iam policy method over gRPC. - - Gets the IAM policy for a given resource. - - Returns: - Callable[[~.GetIamPolicyRequest], - ~.Policy]: - 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_iam_policy' not in self._stubs: - self._stubs['get_iam_policy'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetIamPolicy', - request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, - response_deserializer=policy_pb2.Policy.FromString, - ) - return self._stubs['get_iam_policy'] - - @property - def test_iam_permissions(self) -> Callable[ - [iam_policy_pb2.TestIamPermissionsRequest], - iam_policy_pb2.TestIamPermissionsResponse]: - r"""Return a callable for the test iam permissions method over gRPC. - - Tests if the caller has a list of permissions on a - resource. - - Returns: - Callable[[~.TestIamPermissionsRequest], - ~.TestIamPermissionsResponse]: - 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 'test_iam_permissions' not in self._stubs: - self._stubs['test_iam_permissions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/TestIamPermissions', - request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, - response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, - ) - return self._stubs['test_iam_permissions'] - - @property - def get_project_settings(self) -> Callable[ - [settings.GetProjectSettingsRequest], - settings.ProjectSettings]: - r"""Return a callable for the get project settings method over gRPC. - - Retrieves the Settings for the Project. - - Returns: - Callable[[~.GetProjectSettingsRequest], - ~.ProjectSettings]: - 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_project_settings' not in self._stubs: - self._stubs['get_project_settings'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetProjectSettings', - request_serializer=settings.GetProjectSettingsRequest.serialize, - response_deserializer=settings.ProjectSettings.deserialize, - ) - return self._stubs['get_project_settings'] - - @property - def update_project_settings(self) -> Callable[ - [settings.UpdateProjectSettingsRequest], - settings.ProjectSettings]: - r"""Return a callable for the update project settings method over gRPC. - - Updates the Settings for the Project. - - Returns: - Callable[[~.UpdateProjectSettingsRequest], - ~.ProjectSettings]: - 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_project_settings' not in self._stubs: - self._stubs['update_project_settings'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateProjectSettings', - request_serializer=settings.UpdateProjectSettingsRequest.serialize, - response_deserializer=settings.ProjectSettings.deserialize, - ) - 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'] - - @property - def update_package(self) -> Callable[ - [gda_package.UpdatePackageRequest], - gda_package.Package]: - r"""Return a callable for the update package method over gRPC. - - Updates a package. - - Returns: - Callable[[~.UpdatePackageRequest], - ~.Package]: - 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_package' not in self._stubs: - self._stubs['update_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdatePackage', - request_serializer=gda_package.UpdatePackageRequest.serialize, - response_deserializer=gda_package.Package.deserialize, - ) - return self._stubs['update_package'] - - @property - def list_attachments(self) -> Callable[ - [attachment.ListAttachmentsRequest], - attachment.ListAttachmentsResponse]: - r"""Return a callable for the list attachments method over gRPC. - - Lists attachments. - - Returns: - Callable[[~.ListAttachmentsRequest], - ~.ListAttachmentsResponse]: - 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_attachments' not in self._stubs: - self._stubs['list_attachments'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListAttachments', - request_serializer=attachment.ListAttachmentsRequest.serialize, - response_deserializer=attachment.ListAttachmentsResponse.deserialize, - ) - return self._stubs['list_attachments'] - - @property - def get_attachment(self) -> Callable[ - [attachment.GetAttachmentRequest], - attachment.Attachment]: - r"""Return a callable for the get attachment method over gRPC. - - Gets an attachment. - - Returns: - Callable[[~.GetAttachmentRequest], - ~.Attachment]: - 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_attachment' not in self._stubs: - self._stubs['get_attachment'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetAttachment', - request_serializer=attachment.GetAttachmentRequest.serialize, - response_deserializer=attachment.Attachment.deserialize, - ) - return self._stubs['get_attachment'] - - @property - def create_attachment(self) -> Callable[ - [gda_attachment.CreateAttachmentRequest], - operations_pb2.Operation]: - r"""Return a callable for the create attachment method over gRPC. - - Creates an attachment. The returned Operation will - finish once the attachment has been created. Its - response will be the created attachment. - - Returns: - Callable[[~.CreateAttachmentRequest], - ~.Operation]: - 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 'create_attachment' not in self._stubs: - self._stubs['create_attachment'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateAttachment', - request_serializer=gda_attachment.CreateAttachmentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_attachment'] - - @property - def delete_attachment(self) -> Callable[ - [attachment.DeleteAttachmentRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete attachment method over gRPC. - - Deletes an attachment. The returned Operation will finish once - the attachments has been deleted. It will not have any Operation - metadata and will return a ``google.protobuf.Empty`` response. - - Returns: - Callable[[~.DeleteAttachmentRequest], - ~.Operation]: - 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 'delete_attachment' not in self._stubs: - self._stubs['delete_attachment'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteAttachment', - request_serializer=attachment.DeleteAttachmentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_attachment'] - - 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, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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 "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'ArtifactRegistryGrpcTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py deleted file mode 100644 index e38056401280..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py +++ /dev/null @@ -1,1928 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import inspect -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import exceptions as core_exceptions -from google.api_core import retry_async as retries -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.artifactregistry_v1.types import apt_artifact -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import attachment as gda_attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import file as gda_file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import package as gda_package -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 rule -from google.cloud.artifactregistry_v1.types import rule as gda_rule -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 -from google.cloud.artifactregistry_v1.types import version as gda_version -from google.cloud.artifactregistry_v1.types import vpcsc_config -from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config -from google.cloud.artifactregistry_v1.types import yum_artifact -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 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO -from .grpc import ArtifactRegistryGrpcTransport - - -class ArtifactRegistryGrpcAsyncIOTransport(ArtifactRegistryTransport): - """gRPC AsyncIO backend transport for ArtifactRegistry. - - The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel(cls, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - def __init__(self, *, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if a ``channel`` instance is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if a ``channel`` instance is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]): - A ``Channel`` instance through which to make calls, or a Callable - that constructs and returns one. If set to None, ``self.create_channel`` - is used to create the channel. If a Callable is given, it will be called - with the same arguments as used in ``self.create_channel``. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if a ``channel`` instance is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if isinstance(channel, aio.Channel): - # Ignore credentials if a channel was passed. - credentials = None - self._ignore_credentials = True - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - # initialize with the provided callable or the default channel - channel_init = channel or type(self).create_channel - self._grpc_channel = channel_init( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._wrap_with_kind = "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def list_docker_images(self) -> Callable[ - [artifact.ListDockerImagesRequest], - Awaitable[artifact.ListDockerImagesResponse]]: - r"""Return a callable for the list docker images method over gRPC. - - Lists docker images. - - Returns: - Callable[[~.ListDockerImagesRequest], - Awaitable[~.ListDockerImagesResponse]]: - 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_docker_images' not in self._stubs: - self._stubs['list_docker_images'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListDockerImages', - request_serializer=artifact.ListDockerImagesRequest.serialize, - response_deserializer=artifact.ListDockerImagesResponse.deserialize, - ) - return self._stubs['list_docker_images'] - - @property - def get_docker_image(self) -> Callable[ - [artifact.GetDockerImageRequest], - Awaitable[artifact.DockerImage]]: - r"""Return a callable for the get docker image method over gRPC. - - Gets a docker image. - - Returns: - Callable[[~.GetDockerImageRequest], - Awaitable[~.DockerImage]]: - 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_docker_image' not in self._stubs: - self._stubs['get_docker_image'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetDockerImage', - request_serializer=artifact.GetDockerImageRequest.serialize, - response_deserializer=artifact.DockerImage.deserialize, - ) - 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) -> Callable[ - [apt_artifact.ImportAptArtifactsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the import apt artifacts method over gRPC. - - Imports Apt artifacts. The returned Operation will - complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - Returns: - Callable[[~.ImportAptArtifactsRequest], - Awaitable[~.Operation]]: - 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 'import_apt_artifacts' not in self._stubs: - self._stubs['import_apt_artifacts'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ImportAptArtifacts', - request_serializer=apt_artifact.ImportAptArtifactsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_apt_artifacts'] - - @property - def import_yum_artifacts(self) -> Callable[ - [yum_artifact.ImportYumArtifactsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the import yum artifacts method over gRPC. - - Imports Yum (RPM) artifacts. The returned Operation - will complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - Returns: - Callable[[~.ImportYumArtifactsRequest], - Awaitable[~.Operation]]: - 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 'import_yum_artifacts' not in self._stubs: - self._stubs['import_yum_artifacts'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ImportYumArtifacts', - request_serializer=yum_artifact.ImportYumArtifactsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_yum_artifacts'] - - @property - def list_repositories(self) -> Callable[ - [repository.ListRepositoriesRequest], - Awaitable[repository.ListRepositoriesResponse]]: - r"""Return a callable for the list repositories method over gRPC. - - Lists repositories. - - Returns: - Callable[[~.ListRepositoriesRequest], - Awaitable[~.ListRepositoriesResponse]]: - 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_repositories' not in self._stubs: - self._stubs['list_repositories'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRepositories', - request_serializer=repository.ListRepositoriesRequest.serialize, - response_deserializer=repository.ListRepositoriesResponse.deserialize, - ) - return self._stubs['list_repositories'] - - @property - def get_repository(self) -> Callable[ - [repository.GetRepositoryRequest], - Awaitable[repository.Repository]]: - r"""Return a callable for the get repository method over gRPC. - - Gets a repository. - - Returns: - Callable[[~.GetRepositoryRequest], - Awaitable[~.Repository]]: - 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_repository' not in self._stubs: - self._stubs['get_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRepository', - request_serializer=repository.GetRepositoryRequest.serialize, - response_deserializer=repository.Repository.deserialize, - ) - return self._stubs['get_repository'] - - @property - def create_repository(self) -> Callable[ - [gda_repository.CreateRepositoryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create repository method over gRPC. - - Creates a repository. The returned Operation will - finish once the repository has been created. Its - response will be the created Repository. - - Returns: - Callable[[~.CreateRepositoryRequest], - Awaitable[~.Operation]]: - 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 'create_repository' not in self._stubs: - self._stubs['create_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRepository', - request_serializer=gda_repository.CreateRepositoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_repository'] - - @property - def update_repository(self) -> Callable[ - [gda_repository.UpdateRepositoryRequest], - Awaitable[gda_repository.Repository]]: - r"""Return a callable for the update repository method over gRPC. - - Updates a repository. - - Returns: - Callable[[~.UpdateRepositoryRequest], - Awaitable[~.Repository]]: - 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_repository' not in self._stubs: - self._stubs['update_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRepository', - request_serializer=gda_repository.UpdateRepositoryRequest.serialize, - response_deserializer=gda_repository.Repository.deserialize, - ) - return self._stubs['update_repository'] - - @property - def delete_repository(self) -> Callable[ - [repository.DeleteRepositoryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete repository method over gRPC. - - Deletes a repository and all of its contents. The - returned Operation will finish once the repository has - been deleted. It will not have any Operation metadata - and will return a google.protobuf.Empty response. - - Returns: - Callable[[~.DeleteRepositoryRequest], - Awaitable[~.Operation]]: - 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 'delete_repository' not in self._stubs: - self._stubs['delete_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRepository', - request_serializer=repository.DeleteRepositoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_repository'] - - @property - def list_packages(self) -> Callable[ - [package.ListPackagesRequest], - Awaitable[package.ListPackagesResponse]]: - r"""Return a callable for the list packages method over gRPC. - - Lists packages. - - Returns: - Callable[[~.ListPackagesRequest], - Awaitable[~.ListPackagesResponse]]: - 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_packages' not in self._stubs: - self._stubs['list_packages'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListPackages', - request_serializer=package.ListPackagesRequest.serialize, - response_deserializer=package.ListPackagesResponse.deserialize, - ) - return self._stubs['list_packages'] - - @property - def get_package(self) -> Callable[ - [package.GetPackageRequest], - Awaitable[package.Package]]: - r"""Return a callable for the get package method over gRPC. - - Gets a package. - - Returns: - Callable[[~.GetPackageRequest], - Awaitable[~.Package]]: - 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_package' not in self._stubs: - self._stubs['get_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetPackage', - request_serializer=package.GetPackageRequest.serialize, - response_deserializer=package.Package.deserialize, - ) - return self._stubs['get_package'] - - @property - def delete_package(self) -> Callable[ - [package.DeletePackageRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete package method over gRPC. - - Deletes a package and all of its versions and tags. - The returned operation will complete once the package - has been deleted. - - Returns: - Callable[[~.DeletePackageRequest], - Awaitable[~.Operation]]: - 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 'delete_package' not in self._stubs: - self._stubs['delete_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeletePackage', - request_serializer=package.DeletePackageRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_package'] - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - Awaitable[version.ListVersionsResponse]]: - r"""Return a callable for the list versions method over gRPC. - - Lists versions. - - Returns: - Callable[[~.ListVersionsRequest], - Awaitable[~.ListVersionsResponse]]: - 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_versions' not in self._stubs: - self._stubs['list_versions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListVersions', - request_serializer=version.ListVersionsRequest.serialize, - response_deserializer=version.ListVersionsResponse.deserialize, - ) - return self._stubs['list_versions'] - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - Awaitable[version.Version]]: - r"""Return a callable for the get version method over gRPC. - - Gets a version - - Returns: - Callable[[~.GetVersionRequest], - Awaitable[~.Version]]: - 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_version' not in self._stubs: - self._stubs['get_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetVersion', - request_serializer=version.GetVersionRequest.serialize, - response_deserializer=version.Version.deserialize, - ) - return self._stubs['get_version'] - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete version method over gRPC. - - Deletes a version and all of its content. The - returned operation will complete once the version has - been deleted. - - Returns: - Callable[[~.DeleteVersionRequest], - Awaitable[~.Operation]]: - 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 'delete_version' not in self._stubs: - self._stubs['delete_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteVersion', - request_serializer=version.DeleteVersionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_version'] - - @property - def batch_delete_versions(self) -> Callable[ - [version.BatchDeleteVersionsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the batch delete versions method over gRPC. - - Deletes multiple versions across a repository. The - returned operation will complete once the versions have - been deleted. - - Returns: - Callable[[~.BatchDeleteVersionsRequest], - Awaitable[~.Operation]]: - 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 'batch_delete_versions' not in self._stubs: - self._stubs['batch_delete_versions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/BatchDeleteVersions', - request_serializer=version.BatchDeleteVersionsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['batch_delete_versions'] - - @property - def update_version(self) -> Callable[ - [gda_version.UpdateVersionRequest], - Awaitable[gda_version.Version]]: - r"""Return a callable for the update version method over gRPC. - - Updates a version. - - Returns: - Callable[[~.UpdateVersionRequest], - Awaitable[~.Version]]: - 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_version' not in self._stubs: - self._stubs['update_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVersion', - request_serializer=gda_version.UpdateVersionRequest.serialize, - response_deserializer=gda_version.Version.deserialize, - ) - return self._stubs['update_version'] - - @property - def list_files(self) -> Callable[ - [file.ListFilesRequest], - Awaitable[file.ListFilesResponse]]: - r"""Return a callable for the list files method over gRPC. - - Lists files. - - Returns: - Callable[[~.ListFilesRequest], - Awaitable[~.ListFilesResponse]]: - 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_files' not in self._stubs: - self._stubs['list_files'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListFiles', - request_serializer=file.ListFilesRequest.serialize, - response_deserializer=file.ListFilesResponse.deserialize, - ) - return self._stubs['list_files'] - - @property - def get_file(self) -> Callable[ - [file.GetFileRequest], - Awaitable[file.File]]: - r"""Return a callable for the get file method over gRPC. - - Gets a file. - - Returns: - Callable[[~.GetFileRequest], - Awaitable[~.File]]: - 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_file' not in self._stubs: - self._stubs['get_file'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetFile', - request_serializer=file.GetFileRequest.serialize, - response_deserializer=file.File.deserialize, - ) - return self._stubs['get_file'] - - @property - def delete_file(self) -> Callable[ - [file.DeleteFileRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete file method over gRPC. - - Deletes a file and all of its content. It is only - allowed on generic repositories. The returned operation - will complete once the file has been deleted. - - Returns: - Callable[[~.DeleteFileRequest], - Awaitable[~.Operation]]: - 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 'delete_file' not in self._stubs: - self._stubs['delete_file'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteFile', - request_serializer=file.DeleteFileRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_file'] - - @property - def update_file(self) -> Callable[ - [gda_file.UpdateFileRequest], - Awaitable[gda_file.File]]: - r"""Return a callable for the update file method over gRPC. - - Updates a file. - - Returns: - Callable[[~.UpdateFileRequest], - Awaitable[~.File]]: - 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_file' not in self._stubs: - self._stubs['update_file'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateFile', - request_serializer=gda_file.UpdateFileRequest.serialize, - response_deserializer=gda_file.File.deserialize, - ) - return self._stubs['update_file'] - - @property - def list_tags(self) -> Callable[ - [tag.ListTagsRequest], - Awaitable[tag.ListTagsResponse]]: - r"""Return a callable for the list tags method over gRPC. - - Lists tags. - - Returns: - Callable[[~.ListTagsRequest], - Awaitable[~.ListTagsResponse]]: - 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_tags' not in self._stubs: - self._stubs['list_tags'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListTags', - request_serializer=tag.ListTagsRequest.serialize, - response_deserializer=tag.ListTagsResponse.deserialize, - ) - return self._stubs['list_tags'] - - @property - def get_tag(self) -> Callable[ - [tag.GetTagRequest], - Awaitable[tag.Tag]]: - r"""Return a callable for the get tag method over gRPC. - - Gets a tag. - - Returns: - Callable[[~.GetTagRequest], - Awaitable[~.Tag]]: - 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_tag' not in self._stubs: - self._stubs['get_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetTag', - request_serializer=tag.GetTagRequest.serialize, - response_deserializer=tag.Tag.deserialize, - ) - return self._stubs['get_tag'] - - @property - def create_tag(self) -> Callable[ - [gda_tag.CreateTagRequest], - Awaitable[gda_tag.Tag]]: - r"""Return a callable for the create tag method over gRPC. - - Creates a tag. - - Returns: - Callable[[~.CreateTagRequest], - Awaitable[~.Tag]]: - 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 'create_tag' not in self._stubs: - self._stubs['create_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateTag', - request_serializer=gda_tag.CreateTagRequest.serialize, - response_deserializer=gda_tag.Tag.deserialize, - ) - return self._stubs['create_tag'] - - @property - def update_tag(self) -> Callable[ - [gda_tag.UpdateTagRequest], - Awaitable[gda_tag.Tag]]: - r"""Return a callable for the update tag method over gRPC. - - Updates a tag. - - Returns: - Callable[[~.UpdateTagRequest], - Awaitable[~.Tag]]: - 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_tag' not in self._stubs: - self._stubs['update_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateTag', - request_serializer=gda_tag.UpdateTagRequest.serialize, - response_deserializer=gda_tag.Tag.deserialize, - ) - return self._stubs['update_tag'] - - @property - def delete_tag(self) -> Callable[ - [tag.DeleteTagRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete tag method over gRPC. - - Deletes a tag. - - Returns: - Callable[[~.DeleteTagRequest], - Awaitable[~.Empty]]: - 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 'delete_tag' not in self._stubs: - self._stubs['delete_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteTag', - request_serializer=tag.DeleteTagRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_tag'] - - @property - def create_rule(self) -> Callable[ - [gda_rule.CreateRuleRequest], - Awaitable[gda_rule.Rule]]: - r"""Return a callable for the create rule method over gRPC. - - Creates a rule. - - Returns: - Callable[[~.CreateRuleRequest], - Awaitable[~.Rule]]: - 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 'create_rule' not in self._stubs: - self._stubs['create_rule'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRule', - request_serializer=gda_rule.CreateRuleRequest.serialize, - response_deserializer=gda_rule.Rule.deserialize, - ) - return self._stubs['create_rule'] - - @property - def list_rules(self) -> Callable[ - [rule.ListRulesRequest], - Awaitable[rule.ListRulesResponse]]: - r"""Return a callable for the list rules method over gRPC. - - Lists rules. - - Returns: - Callable[[~.ListRulesRequest], - Awaitable[~.ListRulesResponse]]: - 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_rules' not in self._stubs: - self._stubs['list_rules'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRules', - request_serializer=rule.ListRulesRequest.serialize, - response_deserializer=rule.ListRulesResponse.deserialize, - ) - return self._stubs['list_rules'] - - @property - def get_rule(self) -> Callable[ - [rule.GetRuleRequest], - Awaitable[rule.Rule]]: - r"""Return a callable for the get rule method over gRPC. - - Gets a rule. - - Returns: - Callable[[~.GetRuleRequest], - Awaitable[~.Rule]]: - 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_rule' not in self._stubs: - self._stubs['get_rule'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRule', - request_serializer=rule.GetRuleRequest.serialize, - response_deserializer=rule.Rule.deserialize, - ) - return self._stubs['get_rule'] - - @property - def update_rule(self) -> Callable[ - [gda_rule.UpdateRuleRequest], - Awaitable[gda_rule.Rule]]: - r"""Return a callable for the update rule method over gRPC. - - Updates a rule. - - Returns: - Callable[[~.UpdateRuleRequest], - Awaitable[~.Rule]]: - 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_rule' not in self._stubs: - self._stubs['update_rule'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRule', - request_serializer=gda_rule.UpdateRuleRequest.serialize, - response_deserializer=gda_rule.Rule.deserialize, - ) - return self._stubs['update_rule'] - - @property - def delete_rule(self) -> Callable[ - [rule.DeleteRuleRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete rule method over gRPC. - - Deletes a rule. - - Returns: - Callable[[~.DeleteRuleRequest], - Awaitable[~.Empty]]: - 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 'delete_rule' not in self._stubs: - self._stubs['delete_rule'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRule', - request_serializer=rule.DeleteRuleRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_rule'] - - @property - def set_iam_policy(self) -> Callable[ - [iam_policy_pb2.SetIamPolicyRequest], - Awaitable[policy_pb2.Policy]]: - r"""Return a callable for the set iam policy method over gRPC. - - Updates the IAM policy for a given resource. - - Returns: - Callable[[~.SetIamPolicyRequest], - Awaitable[~.Policy]]: - 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 'set_iam_policy' not in self._stubs: - self._stubs['set_iam_policy'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/SetIamPolicy', - request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, - response_deserializer=policy_pb2.Policy.FromString, - ) - return self._stubs['set_iam_policy'] - - @property - def get_iam_policy(self) -> Callable[ - [iam_policy_pb2.GetIamPolicyRequest], - Awaitable[policy_pb2.Policy]]: - r"""Return a callable for the get iam policy method over gRPC. - - Gets the IAM policy for a given resource. - - Returns: - Callable[[~.GetIamPolicyRequest], - Awaitable[~.Policy]]: - 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_iam_policy' not in self._stubs: - self._stubs['get_iam_policy'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetIamPolicy', - request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, - response_deserializer=policy_pb2.Policy.FromString, - ) - return self._stubs['get_iam_policy'] - - @property - def test_iam_permissions(self) -> Callable[ - [iam_policy_pb2.TestIamPermissionsRequest], - Awaitable[iam_policy_pb2.TestIamPermissionsResponse]]: - r"""Return a callable for the test iam permissions method over gRPC. - - Tests if the caller has a list of permissions on a - resource. - - Returns: - Callable[[~.TestIamPermissionsRequest], - Awaitable[~.TestIamPermissionsResponse]]: - 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 'test_iam_permissions' not in self._stubs: - self._stubs['test_iam_permissions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/TestIamPermissions', - request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, - response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, - ) - return self._stubs['test_iam_permissions'] - - @property - def get_project_settings(self) -> Callable[ - [settings.GetProjectSettingsRequest], - Awaitable[settings.ProjectSettings]]: - r"""Return a callable for the get project settings method over gRPC. - - Retrieves the Settings for the Project. - - Returns: - Callable[[~.GetProjectSettingsRequest], - Awaitable[~.ProjectSettings]]: - 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_project_settings' not in self._stubs: - self._stubs['get_project_settings'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetProjectSettings', - request_serializer=settings.GetProjectSettingsRequest.serialize, - response_deserializer=settings.ProjectSettings.deserialize, - ) - return self._stubs['get_project_settings'] - - @property - def update_project_settings(self) -> Callable[ - [settings.UpdateProjectSettingsRequest], - Awaitable[settings.ProjectSettings]]: - r"""Return a callable for the update project settings method over gRPC. - - Updates the Settings for the Project. - - Returns: - Callable[[~.UpdateProjectSettingsRequest], - Awaitable[~.ProjectSettings]]: - 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_project_settings' not in self._stubs: - self._stubs['update_project_settings'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateProjectSettings', - request_serializer=settings.UpdateProjectSettingsRequest.serialize, - response_deserializer=settings.ProjectSettings.deserialize, - ) - 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'] - - @property - def update_package(self) -> Callable[ - [gda_package.UpdatePackageRequest], - Awaitable[gda_package.Package]]: - r"""Return a callable for the update package method over gRPC. - - Updates a package. - - Returns: - Callable[[~.UpdatePackageRequest], - Awaitable[~.Package]]: - 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_package' not in self._stubs: - self._stubs['update_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdatePackage', - request_serializer=gda_package.UpdatePackageRequest.serialize, - response_deserializer=gda_package.Package.deserialize, - ) - return self._stubs['update_package'] - - @property - def list_attachments(self) -> Callable[ - [attachment.ListAttachmentsRequest], - Awaitable[attachment.ListAttachmentsResponse]]: - r"""Return a callable for the list attachments method over gRPC. - - Lists attachments. - - Returns: - Callable[[~.ListAttachmentsRequest], - Awaitable[~.ListAttachmentsResponse]]: - 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_attachments' not in self._stubs: - self._stubs['list_attachments'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListAttachments', - request_serializer=attachment.ListAttachmentsRequest.serialize, - response_deserializer=attachment.ListAttachmentsResponse.deserialize, - ) - return self._stubs['list_attachments'] - - @property - def get_attachment(self) -> Callable[ - [attachment.GetAttachmentRequest], - Awaitable[attachment.Attachment]]: - r"""Return a callable for the get attachment method over gRPC. - - Gets an attachment. - - Returns: - Callable[[~.GetAttachmentRequest], - Awaitable[~.Attachment]]: - 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_attachment' not in self._stubs: - self._stubs['get_attachment'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/GetAttachment', - request_serializer=attachment.GetAttachmentRequest.serialize, - response_deserializer=attachment.Attachment.deserialize, - ) - return self._stubs['get_attachment'] - - @property - def create_attachment(self) -> Callable[ - [gda_attachment.CreateAttachmentRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create attachment method over gRPC. - - Creates an attachment. The returned Operation will - finish once the attachment has been created. Its - response will be the created attachment. - - Returns: - Callable[[~.CreateAttachmentRequest], - Awaitable[~.Operation]]: - 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 'create_attachment' not in self._stubs: - self._stubs['create_attachment'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateAttachment', - request_serializer=gda_attachment.CreateAttachmentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_attachment'] - - @property - def delete_attachment(self) -> Callable[ - [attachment.DeleteAttachmentRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete attachment method over gRPC. - - Deletes an attachment. The returned Operation will finish once - the attachments has been deleted. It will not have any Operation - metadata and will return a ``google.protobuf.Empty`` response. - - Returns: - Callable[[~.DeleteAttachmentRequest], - Awaitable[~.Operation]]: - 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 'delete_attachment' not in self._stubs: - self._stubs['delete_attachment'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteAttachment', - request_serializer=attachment.DeleteAttachmentRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_attachment'] - - def _prep_wrapped_messages(self, client_info): - """ Precompute the wrapped methods, overriding the base class method to use async wrappers.""" - self._wrapped_methods = { - self.list_docker_images: self._wrap_method( - self.list_docker_images, - default_timeout=None, - client_info=client_info, - ), - self.get_docker_image: self._wrap_method( - self.get_docker_image, - default_timeout=None, - client_info=client_info, - ), - self.list_maven_artifacts: self._wrap_method( - self.list_maven_artifacts, - default_timeout=None, - client_info=client_info, - ), - self.get_maven_artifact: self._wrap_method( - self.get_maven_artifact, - default_timeout=None, - client_info=client_info, - ), - self.list_npm_packages: self._wrap_method( - self.list_npm_packages, - default_timeout=None, - client_info=client_info, - ), - self.get_npm_package: self._wrap_method( - self.get_npm_package, - default_timeout=None, - client_info=client_info, - ), - self.list_python_packages: self._wrap_method( - self.list_python_packages, - default_timeout=None, - client_info=client_info, - ), - self.get_python_package: self._wrap_method( - self.get_python_package, - default_timeout=None, - client_info=client_info, - ), - self.import_apt_artifacts: self._wrap_method( - self.import_apt_artifacts, - default_timeout=None, - client_info=client_info, - ), - self.import_yum_artifacts: self._wrap_method( - self.import_yum_artifacts, - default_timeout=None, - client_info=client_info, - ), - self.list_repositories: self._wrap_method( - self.list_repositories, - default_timeout=None, - client_info=client_info, - ), - self.get_repository: self._wrap_method( - self.get_repository, - default_timeout=None, - client_info=client_info, - ), - self.create_repository: self._wrap_method( - self.create_repository, - default_timeout=None, - client_info=client_info, - ), - self.update_repository: self._wrap_method( - self.update_repository, - default_timeout=None, - client_info=client_info, - ), - self.delete_repository: self._wrap_method( - self.delete_repository, - default_timeout=None, - client_info=client_info, - ), - self.list_packages: self._wrap_method( - self.list_packages, - default_timeout=None, - client_info=client_info, - ), - self.get_package: self._wrap_method( - self.get_package, - default_timeout=None, - client_info=client_info, - ), - self.delete_package: self._wrap_method( - self.delete_package, - default_timeout=None, - client_info=client_info, - ), - self.list_versions: self._wrap_method( - self.list_versions, - default_timeout=None, - client_info=client_info, - ), - self.get_version: self._wrap_method( - self.get_version, - default_timeout=None, - client_info=client_info, - ), - self.delete_version: self._wrap_method( - self.delete_version, - default_timeout=None, - client_info=client_info, - ), - self.batch_delete_versions: self._wrap_method( - self.batch_delete_versions, - default_timeout=None, - client_info=client_info, - ), - self.update_version: self._wrap_method( - self.update_version, - default_timeout=None, - client_info=client_info, - ), - self.list_files: self._wrap_method( - self.list_files, - default_timeout=None, - client_info=client_info, - ), - self.get_file: self._wrap_method( - self.get_file, - default_timeout=None, - client_info=client_info, - ), - self.delete_file: self._wrap_method( - self.delete_file, - default_timeout=None, - client_info=client_info, - ), - self.update_file: self._wrap_method( - self.update_file, - default_timeout=None, - client_info=client_info, - ), - self.list_tags: self._wrap_method( - self.list_tags, - default_timeout=None, - client_info=client_info, - ), - self.get_tag: self._wrap_method( - self.get_tag, - default_timeout=None, - client_info=client_info, - ), - self.create_tag: self._wrap_method( - self.create_tag, - default_timeout=None, - client_info=client_info, - ), - self.update_tag: self._wrap_method( - self.update_tag, - default_timeout=None, - client_info=client_info, - ), - self.delete_tag: self._wrap_method( - self.delete_tag, - default_timeout=None, - client_info=client_info, - ), - self.create_rule: self._wrap_method( - self.create_rule, - default_timeout=None, - client_info=client_info, - ), - self.list_rules: self._wrap_method( - self.list_rules, - default_timeout=None, - client_info=client_info, - ), - self.get_rule: self._wrap_method( - self.get_rule, - default_timeout=None, - client_info=client_info, - ), - self.update_rule: self._wrap_method( - self.update_rule, - default_timeout=None, - client_info=client_info, - ), - self.delete_rule: self._wrap_method( - self.delete_rule, - default_timeout=None, - client_info=client_info, - ), - self.set_iam_policy: self._wrap_method( - self.set_iam_policy, - default_timeout=None, - client_info=client_info, - ), - self.get_iam_policy: self._wrap_method( - self.get_iam_policy, - default_timeout=None, - client_info=client_info, - ), - self.test_iam_permissions: self._wrap_method( - self.test_iam_permissions, - default_timeout=None, - client_info=client_info, - ), - self.get_project_settings: self._wrap_method( - self.get_project_settings, - default_timeout=None, - client_info=client_info, - ), - self.update_project_settings: self._wrap_method( - self.update_project_settings, - default_timeout=None, - client_info=client_info, - ), - self.get_vpcsc_config: self._wrap_method( - self.get_vpcsc_config, - default_timeout=None, - client_info=client_info, - ), - self.update_vpcsc_config: self._wrap_method( - self.update_vpcsc_config, - default_timeout=None, - client_info=client_info, - ), - self.update_package: self._wrap_method( - self.update_package, - default_timeout=None, - client_info=client_info, - ), - self.list_attachments: self._wrap_method( - self.list_attachments, - default_timeout=None, - client_info=client_info, - ), - self.get_attachment: self._wrap_method( - self.get_attachment, - default_timeout=None, - client_info=client_info, - ), - self.create_attachment: self._wrap_method( - self.create_attachment, - default_timeout=None, - client_info=client_info, - ), - self.delete_attachment: self._wrap_method( - self.delete_attachment, - default_timeout=None, - client_info=client_info, - ), - self.get_location: self._wrap_method( - self.get_location, - default_timeout=None, - client_info=client_info, - ), - self.list_locations: self._wrap_method( - self.list_locations, - default_timeout=None, - client_info=client_info, - ), - self.get_operation: self._wrap_method( - self.get_operation, - default_timeout=None, - client_info=client_info, - ), - } - - def _wrap_method(self, func, *args, **kwargs): - if self._wrap_with_kind: # pragma: NO COVER - kwargs["kind"] = self.kind - return gapic_v1.method_async.wrap_method(func, *args, **kwargs) - - def close(self): - return self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc_asyncio" - - @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, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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 "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'ArtifactRegistryGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py deleted file mode 100644 index 2ca1f5fee2f0..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py +++ /dev/null @@ -1,5874 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 google.auth.transport.requests import AuthorizedSession # type: ignore -import json # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.api_core import exceptions as core_exceptions -from google.api_core import retry as retries -from google.api_core import rest_helpers -from google.api_core import rest_streaming -from google.api_core import gapic_v1 - -from google.protobuf import json_format -from google.api_core import operations_v1 -from google.cloud.location import locations_pb2 # type: ignore - -from requests import __version__ as requests_version -import dataclasses -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -import warnings - - -from google.cloud.artifactregistry_v1.types import apt_artifact -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import attachment as gda_attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import file as gda_file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import package as gda_package -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 rule -from google.cloud.artifactregistry_v1.types import rule as gda_rule -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 -from google.cloud.artifactregistry_v1.types import version as gda_version -from google.cloud.artifactregistry_v1.types import vpcsc_config -from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config -from google.cloud.artifactregistry_v1.types import yum_artifact -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.longrunning import operations_pb2 # type: ignore - - -from .rest_base import _BaseArtifactRegistryRestTransport -from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, - grpc_version=None, - rest_version=f"requests@{requests_version}", -) - - -class ArtifactRegistryRestInterceptor: - """Interceptor for ArtifactRegistry. - - Interceptors are used to manipulate requests, request metadata, and responses - in arbitrary ways. - Example use cases include: - * Logging - * Verifying requests according to service or custom semantics - * Stripping extraneous information from responses - - These use cases and more can be enabled by injecting an - instance of a custom subclass when constructing the ArtifactRegistryRestTransport. - - .. code-block:: python - class MyCustomArtifactRegistryInterceptor(ArtifactRegistryRestInterceptor): - def pre_batch_delete_versions(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_batch_delete_versions(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_attachment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_attachment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_repository(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_repository(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_rule(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_rule(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_tag(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_tag(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_attachment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_attachment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_file(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_file(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_package(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_package(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_repository(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_repository(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_rule(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_delete_tag(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_delete_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_version(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_attachment(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_attachment(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_docker_image(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_docker_image(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_file(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_file(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_iam_policy(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_iam_policy(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_maven_artifact(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_maven_artifact(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_npm_package(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_npm_package(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_package(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_package(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_project_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_project_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_python_package(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_python_package(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_repository(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_repository(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_rule(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_rule(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_tag(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_tag(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_version(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_vpcsc_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_vpcsc_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_import_apt_artifacts(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_import_apt_artifacts(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_import_yum_artifacts(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_import_yum_artifacts(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_attachments(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_attachments(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_docker_images(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_docker_images(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_files(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_files(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_maven_artifacts(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_maven_artifacts(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_npm_packages(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_npm_packages(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_packages(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_packages(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_python_packages(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_python_packages(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_repositories(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_repositories(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_rules(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_rules(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_tags(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_tags(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_versions(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_versions(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_set_iam_policy(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_set_iam_policy(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_test_iam_permissions(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_test_iam_permissions(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_file(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_file(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_package(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_package(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_project_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_project_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_repository(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_repository(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_rule(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_rule(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_tag(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_tag(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_version(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_vpcsc_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_vpcsc_config(self, response): - logging.log(f"Received response: {response}") - return response - - transport = ArtifactRegistryRestTransport(interceptor=MyCustomArtifactRegistryInterceptor()) - client = ArtifactRegistryClient(transport=transport) - - - """ - def pre_batch_delete_versions(self, request: version.BatchDeleteVersionsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.BatchDeleteVersionsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for batch_delete_versions - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_batch_delete_versions(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for batch_delete_versions - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_create_attachment(self, request: gda_attachment.CreateAttachmentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_attachment.CreateAttachmentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_attachment - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_create_attachment(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_attachment - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_create_repository(self, request: gda_repository.CreateRepositoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_repository.CreateRepositoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_repository - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_create_repository(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_repository - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_create_rule(self, request: gda_rule.CreateRuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_rule.CreateRuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_rule - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_create_rule(self, response: gda_rule.Rule) -> gda_rule.Rule: - """Post-rpc interceptor for create_rule - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_create_tag(self, request: gda_tag.CreateTagRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_tag.CreateTagRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_tag - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_create_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: - """Post-rpc interceptor for create_tag - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_delete_attachment(self, request: attachment.DeleteAttachmentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[attachment.DeleteAttachmentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_attachment - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_delete_attachment(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_attachment - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_delete_file(self, request: file.DeleteFileRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[file.DeleteFileRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_file - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_delete_file(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_file - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_delete_package(self, request: package.DeletePackageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[package.DeletePackageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_package - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_delete_package(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_package - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_delete_repository(self, request: repository.DeleteRepositoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[repository.DeleteRepositoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_repository - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_delete_repository(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_repository - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_delete_rule(self, request: rule.DeleteRuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[rule.DeleteRuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_rule - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def pre_delete_tag(self, request: tag.DeleteTagRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[tag.DeleteTagRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_tag - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def pre_delete_version(self, request: version.DeleteVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_delete_version(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_version - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_attachment(self, request: attachment.GetAttachmentRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[attachment.GetAttachmentRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_attachment - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_attachment(self, response: attachment.Attachment) -> attachment.Attachment: - """Post-rpc interceptor for get_attachment - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_docker_image(self, request: artifact.GetDockerImageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[artifact.GetDockerImageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_docker_image - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_docker_image(self, response: artifact.DockerImage) -> artifact.DockerImage: - """Post-rpc interceptor for get_docker_image - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_file(self, request: file.GetFileRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[file.GetFileRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_file - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_file(self, response: file.File) -> file.File: - """Post-rpc interceptor for get_file - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_iam_policy(self, request: iam_policy_pb2.GetIamPolicyRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_iam_policy - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: - """Post-rpc interceptor for get_iam_policy - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_maven_artifact(self, request: artifact.GetMavenArtifactRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[artifact.GetMavenArtifactRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_maven_artifact - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_maven_artifact(self, response: artifact.MavenArtifact) -> artifact.MavenArtifact: - """Post-rpc interceptor for get_maven_artifact - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_npm_package(self, request: artifact.GetNpmPackageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[artifact.GetNpmPackageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_npm_package - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_npm_package(self, response: artifact.NpmPackage) -> artifact.NpmPackage: - """Post-rpc interceptor for get_npm_package - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_package(self, request: package.GetPackageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[package.GetPackageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_package - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_package(self, response: package.Package) -> package.Package: - """Post-rpc interceptor for get_package - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_project_settings(self, request: settings.GetProjectSettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[settings.GetProjectSettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_project_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_project_settings(self, response: settings.ProjectSettings) -> settings.ProjectSettings: - """Post-rpc interceptor for get_project_settings - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_python_package(self, request: artifact.GetPythonPackageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[artifact.GetPythonPackageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_python_package - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_python_package(self, response: artifact.PythonPackage) -> artifact.PythonPackage: - """Post-rpc interceptor for get_python_package - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_repository(self, request: repository.GetRepositoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[repository.GetRepositoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_repository - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_repository(self, response: repository.Repository) -> repository.Repository: - """Post-rpc interceptor for get_repository - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_rule(self, request: rule.GetRuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[rule.GetRuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_rule - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_rule(self, response: rule.Rule) -> rule.Rule: - """Post-rpc interceptor for get_rule - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_tag(self, request: tag.GetTagRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[tag.GetTagRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_tag - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_tag(self, response: tag.Tag) -> tag.Tag: - """Post-rpc interceptor for get_tag - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_version(self, request: version.GetVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_version(self, response: version.Version) -> version.Version: - """Post-rpc interceptor for get_version - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_vpcsc_config(self, request: vpcsc_config.GetVPCSCConfigRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[vpcsc_config.GetVPCSCConfigRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_vpcsc_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_vpcsc_config(self, response: vpcsc_config.VPCSCConfig) -> vpcsc_config.VPCSCConfig: - """Post-rpc interceptor for get_vpcsc_config - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_import_apt_artifacts(self, request: apt_artifact.ImportAptArtifactsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[apt_artifact.ImportAptArtifactsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for import_apt_artifacts - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_import_apt_artifacts(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for import_apt_artifacts - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_import_yum_artifacts(self, request: yum_artifact.ImportYumArtifactsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[yum_artifact.ImportYumArtifactsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for import_yum_artifacts - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_import_yum_artifacts(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for import_yum_artifacts - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_attachments(self, request: attachment.ListAttachmentsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[attachment.ListAttachmentsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_attachments - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_attachments(self, response: attachment.ListAttachmentsResponse) -> attachment.ListAttachmentsResponse: - """Post-rpc interceptor for list_attachments - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_docker_images(self, request: artifact.ListDockerImagesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[artifact.ListDockerImagesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_docker_images - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_docker_images(self, response: artifact.ListDockerImagesResponse) -> artifact.ListDockerImagesResponse: - """Post-rpc interceptor for list_docker_images - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_files(self, request: file.ListFilesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[file.ListFilesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_files - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_files(self, response: file.ListFilesResponse) -> file.ListFilesResponse: - """Post-rpc interceptor for list_files - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_maven_artifacts(self, request: artifact.ListMavenArtifactsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[artifact.ListMavenArtifactsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_maven_artifacts - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_maven_artifacts(self, response: artifact.ListMavenArtifactsResponse) -> artifact.ListMavenArtifactsResponse: - """Post-rpc interceptor for list_maven_artifacts - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_npm_packages(self, request: artifact.ListNpmPackagesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[artifact.ListNpmPackagesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_npm_packages - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_npm_packages(self, response: artifact.ListNpmPackagesResponse) -> artifact.ListNpmPackagesResponse: - """Post-rpc interceptor for list_npm_packages - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_packages(self, request: package.ListPackagesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[package.ListPackagesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_packages - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_packages(self, response: package.ListPackagesResponse) -> package.ListPackagesResponse: - """Post-rpc interceptor for list_packages - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_python_packages(self, request: artifact.ListPythonPackagesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[artifact.ListPythonPackagesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_python_packages - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_python_packages(self, response: artifact.ListPythonPackagesResponse) -> artifact.ListPythonPackagesResponse: - """Post-rpc interceptor for list_python_packages - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_repositories(self, request: repository.ListRepositoriesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[repository.ListRepositoriesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_repositories - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_repositories(self, response: repository.ListRepositoriesResponse) -> repository.ListRepositoriesResponse: - """Post-rpc interceptor for list_repositories - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_rules(self, request: rule.ListRulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[rule.ListRulesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_rules - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_rules(self, response: rule.ListRulesResponse) -> rule.ListRulesResponse: - """Post-rpc interceptor for list_rules - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_tags(self, request: tag.ListTagsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[tag.ListTagsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_tags - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_tags(self, response: tag.ListTagsResponse) -> tag.ListTagsResponse: - """Post-rpc interceptor for list_tags - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_versions(self, request: version.ListVersionsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_versions - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_versions(self, response: version.ListVersionsResponse) -> version.ListVersionsResponse: - """Post-rpc interceptor for list_versions - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_set_iam_policy(self, request: iam_policy_pb2.SetIamPolicyRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for set_iam_policy - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: - """Post-rpc interceptor for set_iam_policy - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_test_iam_permissions(self, request: iam_policy_pb2.TestIamPermissionsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for test_iam_permissions - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_test_iam_permissions(self, response: iam_policy_pb2.TestIamPermissionsResponse) -> iam_policy_pb2.TestIamPermissionsResponse: - """Post-rpc interceptor for test_iam_permissions - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_file(self, request: gda_file.UpdateFileRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_file.UpdateFileRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_file - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_file(self, response: gda_file.File) -> gda_file.File: - """Post-rpc interceptor for update_file - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_package(self, request: gda_package.UpdatePackageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_package.UpdatePackageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_package - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_package(self, response: gda_package.Package) -> gda_package.Package: - """Post-rpc interceptor for update_package - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_project_settings(self, request: settings.UpdateProjectSettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[settings.UpdateProjectSettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_project_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_project_settings(self, response: settings.ProjectSettings) -> settings.ProjectSettings: - """Post-rpc interceptor for update_project_settings - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_repository(self, request: gda_repository.UpdateRepositoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_repository.UpdateRepositoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_repository - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_repository(self, response: gda_repository.Repository) -> gda_repository.Repository: - """Post-rpc interceptor for update_repository - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_rule(self, request: gda_rule.UpdateRuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_rule.UpdateRuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_rule - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_rule(self, response: gda_rule.Rule) -> gda_rule.Rule: - """Post-rpc interceptor for update_rule - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_tag(self, request: gda_tag.UpdateTagRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_tag.UpdateTagRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_tag - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: - """Post-rpc interceptor for update_tag - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_version(self, request: gda_version.UpdateVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_version.UpdateVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_version(self, response: gda_version.Version) -> gda_version.Version: - """Post-rpc interceptor for update_version - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_vpcsc_config(self, request: gda_vpcsc_config.UpdateVPCSCConfigRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_vpcsc_config.UpdateVPCSCConfigRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_vpcsc_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_vpcsc_config(self, response: gda_vpcsc_config.VPCSCConfig) -> gda_vpcsc_config.VPCSCConfig: - """Post-rpc interceptor for update_vpcsc_config - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_operation( - self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_operation( - self, response: operations_pb2.Operation - ) -> operations_pb2.Operation: - """Post-rpc interceptor for get_operation - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class ArtifactRegistryRestStub: - _session: AuthorizedSession - _host: str - _interceptor: ArtifactRegistryRestInterceptor - - -class ArtifactRegistryRestTransport(_BaseArtifactRegistryRestTransport): - """REST backend synchronous transport for ArtifactRegistry. - - The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends JSON representations of protocol buffers over HTTP/1.1 - """ - - def __init__(self, *, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - client_cert_source_for_mtls: Optional[Callable[[ - ], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = 'https', - interceptor: Optional[ArtifactRegistryRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client - certificate to configure mutual TLS HTTP channel. It is ignored - if ``channel`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. - # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the - # credentials object - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - url_scheme=url_scheme, - api_audience=api_audience - ) - self._session = AuthorizedSession( - self._credentials, default_host=self.DEFAULT_HOST) - self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or ArtifactRegistryRestInterceptor() - self._prep_wrapped_messages(client_info) - - @property - def operations_client(self) -> operations_v1.AbstractOperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Only create a new client if we do not already have one. - if self._operations_client is None: - http_options: Dict[str, List[Dict[str, str]]] = { - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, - ], - } - - rest_transport = operations_v1.OperationsRestTransport( - host=self._host, - # use the credentials which are saved - credentials=self._credentials, - scopes=self._scopes, - http_options=http_options, - path_prefix="v1") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _BatchDeleteVersions(_BaseArtifactRegistryRestTransport._BaseBatchDeleteVersions, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.BatchDeleteVersions") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: version.BatchDeleteVersionsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the batch delete versions method over HTTP. - - Args: - request (~.version.BatchDeleteVersionsRequest): - The request object. The request to delete multiple - versions across a repository. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseBatchDeleteVersions._get_http_options() - request, metadata = self._interceptor.pre_batch_delete_versions(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseBatchDeleteVersions._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseBatchDeleteVersions._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseBatchDeleteVersions._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._BatchDeleteVersions._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_batch_delete_versions(resp) - return resp - - class _CreateAttachment(_BaseArtifactRegistryRestTransport._BaseCreateAttachment, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.CreateAttachment") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_attachment.CreateAttachmentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the create attachment method over HTTP. - - Args: - request (~.gda_attachment.CreateAttachmentRequest): - The request object. The request to create a new - attachment. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_http_options() - request, metadata = self._interceptor.pre_create_attachment(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._CreateAttachment._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_attachment(resp) - return resp - - class _CreateRepository(_BaseArtifactRegistryRestTransport._BaseCreateRepository, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.CreateRepository") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_repository.CreateRepositoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the create repository method over HTTP. - - Args: - request (~.gda_repository.CreateRepositoryRequest): - The request object. The request to create a new - repository. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_http_options() - request, metadata = self._interceptor.pre_create_repository(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._CreateRepository._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_repository(resp) - return resp - - class _CreateRule(_BaseArtifactRegistryRestTransport._BaseCreateRule, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.CreateRule") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_rule.CreateRuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_rule.Rule: - r"""Call the create rule method over HTTP. - - Args: - request (~.gda_rule.CreateRuleRequest): - The request object. The request to create a new rule. - 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: - ~.gda_rule.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseCreateRule._get_http_options() - request, metadata = self._interceptor.pre_create_rule(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateRule._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseCreateRule._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseCreateRule._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._CreateRule._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_rule.Rule() - pb_resp = gda_rule.Rule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_rule(resp) - return resp - - class _CreateTag(_BaseArtifactRegistryRestTransport._BaseCreateTag, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.CreateTag") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_tag.CreateTagRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_tag.Tag: - r"""Call the create tag method over HTTP. - - Args: - request (~.gda_tag.CreateTagRequest): - The request object. The request to create a new tag. - 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: - ~.gda_tag.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_http_options() - request, metadata = self._interceptor.pre_create_tag(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._CreateTag._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_tag.Tag() - pb_resp = gda_tag.Tag.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_tag(resp) - return resp - - class _DeleteAttachment(_BaseArtifactRegistryRestTransport._BaseDeleteAttachment, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteAttachment") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: attachment.DeleteAttachmentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete attachment method over HTTP. - - Args: - request (~.attachment.DeleteAttachmentRequest): - The request object. The request to delete an attachment. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_http_options() - request, metadata = self._interceptor.pre_delete_attachment(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteAttachment._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_attachment(resp) - return resp - - class _DeleteFile(_BaseArtifactRegistryRestTransport._BaseDeleteFile, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteFile") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: file.DeleteFileRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete file method over HTTP. - - Args: - request (~.file.DeleteFileRequest): - The request object. The request to delete a file. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_http_options() - request, metadata = self._interceptor.pre_delete_file(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteFile._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_file(resp) - return resp - - class _DeletePackage(_BaseArtifactRegistryRestTransport._BaseDeletePackage, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeletePackage") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: package.DeletePackageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete package method over HTTP. - - Args: - request (~.package.DeletePackageRequest): - The request object. The request to delete a package. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_http_options() - request, metadata = self._interceptor.pre_delete_package(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeletePackage._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_package(resp) - return resp - - class _DeleteRepository(_BaseArtifactRegistryRestTransport._BaseDeleteRepository, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteRepository") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: repository.DeleteRepositoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete repository method over HTTP. - - Args: - request (~.repository.DeleteRepositoryRequest): - The request object. The request to delete a repository. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_http_options() - request, metadata = self._interceptor.pre_delete_repository(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteRepository._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_repository(resp) - return resp - - class _DeleteRule(_BaseArtifactRegistryRestTransport._BaseDeleteRule, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteRule") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: rule.DeleteRuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete rule method over HTTP. - - Args: - request (~.rule.DeleteRuleRequest): - The request object. The request to delete a rule. - 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. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_http_options() - request, metadata = self._interceptor.pre_delete_rule(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteRule._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeleteTag(_BaseArtifactRegistryRestTransport._BaseDeleteTag, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteTag") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: tag.DeleteTagRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete tag method over HTTP. - - Args: - request (~.tag.DeleteTagRequest): - The request object. The request to delete a tag. - 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. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_http_options() - request, metadata = self._interceptor.pre_delete_tag(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteTag._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeleteVersion(_BaseArtifactRegistryRestTransport._BaseDeleteVersion, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteVersion") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: version.DeleteVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete version method over HTTP. - - Args: - request (~.version.DeleteVersionRequest): - The request object. The request to delete a version. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_http_options() - request, metadata = self._interceptor.pre_delete_version(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteVersion._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_version(resp) - return resp - - class _GetAttachment(_BaseArtifactRegistryRestTransport._BaseGetAttachment, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetAttachment") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: attachment.GetAttachmentRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> attachment.Attachment: - r"""Call the get attachment method over HTTP. - - Args: - request (~.attachment.GetAttachmentRequest): - The request object. The request to retrieve an - attachment. - 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: - ~.attachment.Attachment: - An Attachment refers to additional - metadata that can be attached to - artifacts in Artifact Registry. An - attachment consists of one or more - files. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_http_options() - request, metadata = self._interceptor.pre_get_attachment(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetAttachment._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = attachment.Attachment() - pb_resp = attachment.Attachment.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_attachment(resp) - return resp - - class _GetDockerImage(_BaseArtifactRegistryRestTransport._BaseGetDockerImage, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetDockerImage") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: artifact.GetDockerImageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> artifact.DockerImage: - r"""Call the get docker image method over HTTP. - - Args: - request (~.artifact.GetDockerImageRequest): - The request object. The request to get docker images. - 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: - ~.artifact.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 - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetDockerImage._get_http_options() - request, metadata = self._interceptor.pre_get_docker_image(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetDockerImage._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetDockerImage._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetDockerImage._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = artifact.DockerImage() - pb_resp = artifact.DockerImage.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_docker_image(resp) - return resp - - class _GetFile(_BaseArtifactRegistryRestTransport._BaseGetFile, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetFile") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: file.GetFileRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> file.File: - r"""Call the get file method over HTTP. - - Args: - request (~.file.GetFileRequest): - The request object. The request to retrieve a file. - 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: - ~.file.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetFile._get_http_options() - request, metadata = self._interceptor.pre_get_file(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetFile._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetFile._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetFile._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = file.File() - pb_resp = file.File.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_file(resp) - return resp - - class _GetIamPolicy(_BaseArtifactRegistryRestTransport._BaseGetIamPolicy, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetIamPolicy") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: iam_policy_pb2.GetIamPolicyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> policy_pb2.Policy: - r"""Call the get iam policy method over HTTP. - - Args: - request (~.iam_policy_pb2.GetIamPolicyRequest): - The request object. Request message for ``GetIamPolicy`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which - specifies access controls for Google Cloud resources. - - A ``Policy`` is a collection of ``bindings``. A - ``binding`` binds one or more ``members``, or - principals, to a single ``role``. Principals can be user - accounts, service accounts, Google groups, and domains - (such as G Suite). A ``role`` is a named list of - permissions; each ``role`` can be an IAM predefined role - or a user-created custom role. - - For some types of Google Cloud resources, a ``binding`` - can also specify a ``condition``, which is a logical - expression that allows access to a resource only if the - expression evaluates to ``true``. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the `IAM - documentation `__. - - **JSON example:** - - :: - - { - "bindings": [ - { - "role": "roles/resourcemanager.organizationAdmin", - "members": [ - "user:mike@example.com", - "group:admins@example.com", - "domain:google.com", - "serviceAccount:my-project-id@appspot.gserviceaccount.com" - ] - }, - { - "role": "roles/resourcemanager.organizationViewer", - "members": [ - "user:eve@example.com" - ], - "condition": { - "title": "expirable access", - "description": "Does not grant access after Sep 2020", - "expression": "request.time < - timestamp('2020-10-01T00:00:00.000Z')", - } - } - ], - "etag": "BwWWja0YfJA=", - "version": 3 - } - - **YAML example:** - - :: - - bindings: - - members: - - user:mike@example.com - - group:admins@example.com - - domain:google.com - - serviceAccount:my-project-id@appspot.gserviceaccount.com - role: roles/resourcemanager.organizationAdmin - - members: - - user:eve@example.com - role: roles/resourcemanager.organizationViewer - condition: - title: expirable access - description: Does not grant access after Sep 2020 - expression: request.time < timestamp('2020-10-01T00:00:00.000Z') - etag: BwWWja0YfJA= - version: 3 - - For a description of IAM and its features, see the `IAM - documentation `__. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_http_options() - request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetIamPolicy._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = policy_pb2.Policy() - pb_resp = resp - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_iam_policy(resp) - return resp - - class _GetMavenArtifact(_BaseArtifactRegistryRestTransport._BaseGetMavenArtifact, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetMavenArtifact") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: artifact.GetMavenArtifactRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> artifact.MavenArtifact: - r"""Call the get maven artifact method over HTTP. - - Args: - request (~.artifact.GetMavenArtifactRequest): - The request object. The request to get maven artifacts. - 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: - ~.artifact.MavenArtifact: - MavenArtifact represents a maven - artifact. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetMavenArtifact._get_http_options() - request, metadata = self._interceptor.pre_get_maven_artifact(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetMavenArtifact._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetMavenArtifact._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetMavenArtifact._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = artifact.MavenArtifact() - pb_resp = artifact.MavenArtifact.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_maven_artifact(resp) - return resp - - class _GetNpmPackage(_BaseArtifactRegistryRestTransport._BaseGetNpmPackage, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetNpmPackage") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: artifact.GetNpmPackageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> artifact.NpmPackage: - r"""Call the get npm package method over HTTP. - - Args: - request (~.artifact.GetNpmPackageRequest): - The request object. The request to get npm packages. - 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: - ~.artifact.NpmPackage: - NpmPackage represents an npm - artifact. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetNpmPackage._get_http_options() - request, metadata = self._interceptor.pre_get_npm_package(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetNpmPackage._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetNpmPackage._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetNpmPackage._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = artifact.NpmPackage() - pb_resp = artifact.NpmPackage.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_npm_package(resp) - return resp - - class _GetPackage(_BaseArtifactRegistryRestTransport._BaseGetPackage, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetPackage") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: package.GetPackageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> package.Package: - r"""Call the get package method over HTTP. - - Args: - request (~.package.GetPackageRequest): - The request object. The request to retrieve a package. - 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: - ~.package.Package: - Packages are named collections of - versions. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetPackage._get_http_options() - request, metadata = self._interceptor.pre_get_package(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetPackage._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetPackage._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetPackage._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = package.Package() - pb_resp = package.Package.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_package(resp) - return resp - - class _GetProjectSettings(_BaseArtifactRegistryRestTransport._BaseGetProjectSettings, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetProjectSettings") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: settings.GetProjectSettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> settings.ProjectSettings: - r"""Call the get project settings method over HTTP. - - Args: - request (~.settings.GetProjectSettingsRequest): - The request object. Gets the redirection status for a - project. - 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: - ~.settings.ProjectSettings: - The Artifact Registry settings that - apply to a Project. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_http_options() - request, metadata = self._interceptor.pre_get_project_settings(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetProjectSettings._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = settings.ProjectSettings() - pb_resp = settings.ProjectSettings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_project_settings(resp) - return resp - - class _GetPythonPackage(_BaseArtifactRegistryRestTransport._BaseGetPythonPackage, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetPythonPackage") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: artifact.GetPythonPackageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> artifact.PythonPackage: - r"""Call the get python package method over HTTP. - - Args: - request (~.artifact.GetPythonPackageRequest): - The request object. The request to get python packages. - 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: - ~.artifact.PythonPackage: - PythonPackage represents a python - artifact. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetPythonPackage._get_http_options() - request, metadata = self._interceptor.pre_get_python_package(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetPythonPackage._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetPythonPackage._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetPythonPackage._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = artifact.PythonPackage() - pb_resp = artifact.PythonPackage.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_python_package(resp) - return resp - - class _GetRepository(_BaseArtifactRegistryRestTransport._BaseGetRepository, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetRepository") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: repository.GetRepositoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> repository.Repository: - r"""Call the get repository method over HTTP. - - Args: - request (~.repository.GetRepositoryRequest): - The request object. The request to retrieve a repository. - 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: - ~.repository.Repository: - A Repository for storing artifacts - with a specific format. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetRepository._get_http_options() - request, metadata = self._interceptor.pre_get_repository(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetRepository._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetRepository._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetRepository._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = repository.Repository() - pb_resp = repository.Repository.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_repository(resp) - return resp - - class _GetRule(_BaseArtifactRegistryRestTransport._BaseGetRule, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetRule") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: rule.GetRuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> rule.Rule: - r"""Call the get rule method over HTTP. - - Args: - request (~.rule.GetRuleRequest): - The request object. The request to retrieve a rule. - 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: - ~.rule.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetRule._get_http_options() - request, metadata = self._interceptor.pre_get_rule(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetRule._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetRule._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetRule._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = rule.Rule() - pb_resp = rule.Rule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_rule(resp) - return resp - - class _GetTag(_BaseArtifactRegistryRestTransport._BaseGetTag, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetTag") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: tag.GetTagRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> tag.Tag: - r"""Call the get tag method over HTTP. - - Args: - request (~.tag.GetTagRequest): - The request object. The request to retrieve a tag. - 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: - ~.tag.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetTag._get_http_options() - request, metadata = self._interceptor.pre_get_tag(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetTag._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetTag._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetTag._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = tag.Tag() - pb_resp = tag.Tag.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_tag(resp) - return resp - - class _GetVersion(_BaseArtifactRegistryRestTransport._BaseGetVersion, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetVersion") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: version.GetVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> version.Version: - r"""Call the get version method over HTTP. - - Args: - request (~.version.GetVersionRequest): - The request object. The request to retrieve a version. - 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: - ~.version.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetVersion._get_http_options() - request, metadata = self._interceptor.pre_get_version(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetVersion._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetVersion._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetVersion._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = version.Version() - pb_resp = version.Version.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_version(resp) - return resp - - class _GetVPCSCConfig(_BaseArtifactRegistryRestTransport._BaseGetVPCSCConfig, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetVPCSCConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: vpcsc_config.GetVPCSCConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> vpcsc_config.VPCSCConfig: - r"""Call the get vpcsc config method over HTTP. - - Args: - request (~.vpcsc_config.GetVPCSCConfigRequest): - The request object. Gets the VPC SC config for a project. - 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: - ~.vpcsc_config.VPCSCConfig: - The Artifact Registry VPC SC config - that apply to a Project. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetVPCSCConfig._get_http_options() - request, metadata = self._interceptor.pre_get_vpcsc_config(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetVPCSCConfig._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetVPCSCConfig._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetVPCSCConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = vpcsc_config.VPCSCConfig() - pb_resp = vpcsc_config.VPCSCConfig.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_vpcsc_config(resp) - return resp - - class _ImportAptArtifacts(_BaseArtifactRegistryRestTransport._BaseImportAptArtifacts, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ImportAptArtifacts") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: apt_artifact.ImportAptArtifactsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the import apt artifacts method over HTTP. - - Args: - request (~.apt_artifact.ImportAptArtifactsRequest): - The request object. The request to import new apt - artifacts. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_http_options() - request, metadata = self._interceptor.pre_import_apt_artifacts(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ImportAptArtifacts._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_import_apt_artifacts(resp) - return resp - - class _ImportYumArtifacts(_BaseArtifactRegistryRestTransport._BaseImportYumArtifacts, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ImportYumArtifacts") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: yum_artifact.ImportYumArtifactsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the import yum artifacts method over HTTP. - - Args: - request (~.yum_artifact.ImportYumArtifactsRequest): - The request object. The request to import new yum - artifacts. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_http_options() - request, metadata = self._interceptor.pre_import_yum_artifacts(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ImportYumArtifacts._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_import_yum_artifacts(resp) - return resp - - class _ListAttachments(_BaseArtifactRegistryRestTransport._BaseListAttachments, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListAttachments") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: attachment.ListAttachmentsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> attachment.ListAttachmentsResponse: - r"""Call the list attachments method over HTTP. - - Args: - request (~.attachment.ListAttachmentsRequest): - The request object. The request to list attachments. - 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: - ~.attachment.ListAttachmentsResponse: - The response from listing - attachments. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListAttachments._get_http_options() - request, metadata = self._interceptor.pre_list_attachments(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListAttachments._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListAttachments._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListAttachments._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = attachment.ListAttachmentsResponse() - pb_resp = attachment.ListAttachmentsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_attachments(resp) - return resp - - class _ListDockerImages(_BaseArtifactRegistryRestTransport._BaseListDockerImages, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListDockerImages") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: artifact.ListDockerImagesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> artifact.ListDockerImagesResponse: - r"""Call the list docker images method over HTTP. - - Args: - request (~.artifact.ListDockerImagesRequest): - The request object. The request to list docker images. - 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: - ~.artifact.ListDockerImagesResponse: - The response from listing docker - images. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListDockerImages._get_http_options() - request, metadata = self._interceptor.pre_list_docker_images(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListDockerImages._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListDockerImages._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListDockerImages._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = artifact.ListDockerImagesResponse() - pb_resp = artifact.ListDockerImagesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_docker_images(resp) - return resp - - class _ListFiles(_BaseArtifactRegistryRestTransport._BaseListFiles, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListFiles") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: file.ListFilesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> file.ListFilesResponse: - r"""Call the list files method over HTTP. - - Args: - request (~.file.ListFilesRequest): - The request object. The request to list files. - 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: - ~.file.ListFilesResponse: - The response from listing files. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListFiles._get_http_options() - request, metadata = self._interceptor.pre_list_files(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListFiles._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListFiles._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListFiles._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = file.ListFilesResponse() - pb_resp = file.ListFilesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_files(resp) - return resp - - class _ListMavenArtifacts(_BaseArtifactRegistryRestTransport._BaseListMavenArtifacts, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListMavenArtifacts") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: artifact.ListMavenArtifactsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> artifact.ListMavenArtifactsResponse: - r"""Call the list maven artifacts method over HTTP. - - Args: - request (~.artifact.ListMavenArtifactsRequest): - The request object. The request to list maven artifacts. - 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: - ~.artifact.ListMavenArtifactsResponse: - The response from listing maven - artifacts. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListMavenArtifacts._get_http_options() - request, metadata = self._interceptor.pre_list_maven_artifacts(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListMavenArtifacts._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListMavenArtifacts._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListMavenArtifacts._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = artifact.ListMavenArtifactsResponse() - pb_resp = artifact.ListMavenArtifactsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_maven_artifacts(resp) - return resp - - class _ListNpmPackages(_BaseArtifactRegistryRestTransport._BaseListNpmPackages, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListNpmPackages") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: artifact.ListNpmPackagesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> artifact.ListNpmPackagesResponse: - r"""Call the list npm packages method over HTTP. - - Args: - request (~.artifact.ListNpmPackagesRequest): - The request object. The request to list npm packages. - 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: - ~.artifact.ListNpmPackagesResponse: - The response from listing npm - packages. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListNpmPackages._get_http_options() - request, metadata = self._interceptor.pre_list_npm_packages(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListNpmPackages._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListNpmPackages._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListNpmPackages._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = artifact.ListNpmPackagesResponse() - pb_resp = artifact.ListNpmPackagesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_npm_packages(resp) - return resp - - class _ListPackages(_BaseArtifactRegistryRestTransport._BaseListPackages, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListPackages") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: package.ListPackagesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> package.ListPackagesResponse: - r"""Call the list packages method over HTTP. - - Args: - request (~.package.ListPackagesRequest): - The request object. The request to list packages. - 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: - ~.package.ListPackagesResponse: - The response from listing packages. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListPackages._get_http_options() - request, metadata = self._interceptor.pre_list_packages(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListPackages._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListPackages._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListPackages._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = package.ListPackagesResponse() - pb_resp = package.ListPackagesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_packages(resp) - return resp - - class _ListPythonPackages(_BaseArtifactRegistryRestTransport._BaseListPythonPackages, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListPythonPackages") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: artifact.ListPythonPackagesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> artifact.ListPythonPackagesResponse: - r"""Call the list python packages method over HTTP. - - Args: - request (~.artifact.ListPythonPackagesRequest): - The request object. The request to list python packages. - 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: - ~.artifact.ListPythonPackagesResponse: - The response from listing python - packages. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListPythonPackages._get_http_options() - request, metadata = self._interceptor.pre_list_python_packages(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListPythonPackages._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListPythonPackages._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListPythonPackages._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = artifact.ListPythonPackagesResponse() - pb_resp = artifact.ListPythonPackagesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_python_packages(resp) - return resp - - class _ListRepositories(_BaseArtifactRegistryRestTransport._BaseListRepositories, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListRepositories") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: repository.ListRepositoriesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> repository.ListRepositoriesResponse: - r"""Call the list repositories method over HTTP. - - Args: - request (~.repository.ListRepositoriesRequest): - The request object. The request to list repositories. - 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: - ~.repository.ListRepositoriesResponse: - The response from listing - repositories. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListRepositories._get_http_options() - request, metadata = self._interceptor.pre_list_repositories(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListRepositories._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListRepositories._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListRepositories._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = repository.ListRepositoriesResponse() - pb_resp = repository.ListRepositoriesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_repositories(resp) - return resp - - class _ListRules(_BaseArtifactRegistryRestTransport._BaseListRules, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListRules") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: rule.ListRulesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> rule.ListRulesResponse: - r"""Call the list rules method over HTTP. - - Args: - request (~.rule.ListRulesRequest): - The request object. The request to list rules. - 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: - ~.rule.ListRulesResponse: - The response from listing rules. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListRules._get_http_options() - request, metadata = self._interceptor.pre_list_rules(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListRules._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListRules._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListRules._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = rule.ListRulesResponse() - pb_resp = rule.ListRulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_rules(resp) - return resp - - class _ListTags(_BaseArtifactRegistryRestTransport._BaseListTags, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListTags") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: tag.ListTagsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> tag.ListTagsResponse: - r"""Call the list tags method over HTTP. - - Args: - request (~.tag.ListTagsRequest): - The request object. The request to list tags. - 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: - ~.tag.ListTagsResponse: - The response from listing tags. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListTags._get_http_options() - request, metadata = self._interceptor.pre_list_tags(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListTags._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListTags._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListTags._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = tag.ListTagsResponse() - pb_resp = tag.ListTagsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_tags(resp) - return resp - - class _ListVersions(_BaseArtifactRegistryRestTransport._BaseListVersions, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListVersions") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: version.ListVersionsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> version.ListVersionsResponse: - r"""Call the list versions method over HTTP. - - Args: - request (~.version.ListVersionsRequest): - The request object. The request to list versions. - 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: - ~.version.ListVersionsResponse: - The response from listing versions. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListVersions._get_http_options() - request, metadata = self._interceptor.pre_list_versions(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListVersions._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListVersions._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListVersions._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = version.ListVersionsResponse() - pb_resp = version.ListVersionsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_versions(resp) - return resp - - class _SetIamPolicy(_BaseArtifactRegistryRestTransport._BaseSetIamPolicy, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.SetIamPolicy") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: iam_policy_pb2.SetIamPolicyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> policy_pb2.Policy: - r"""Call the set iam policy method over HTTP. - - Args: - request (~.iam_policy_pb2.SetIamPolicyRequest): - The request object. Request message for ``SetIamPolicy`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which - specifies access controls for Google Cloud resources. - - A ``Policy`` is a collection of ``bindings``. A - ``binding`` binds one or more ``members``, or - principals, to a single ``role``. Principals can be user - accounts, service accounts, Google groups, and domains - (such as G Suite). A ``role`` is a named list of - permissions; each ``role`` can be an IAM predefined role - or a user-created custom role. - - For some types of Google Cloud resources, a ``binding`` - can also specify a ``condition``, which is a logical - expression that allows access to a resource only if the - expression evaluates to ``true``. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the `IAM - documentation `__. - - **JSON example:** - - :: - - { - "bindings": [ - { - "role": "roles/resourcemanager.organizationAdmin", - "members": [ - "user:mike@example.com", - "group:admins@example.com", - "domain:google.com", - "serviceAccount:my-project-id@appspot.gserviceaccount.com" - ] - }, - { - "role": "roles/resourcemanager.organizationViewer", - "members": [ - "user:eve@example.com" - ], - "condition": { - "title": "expirable access", - "description": "Does not grant access after Sep 2020", - "expression": "request.time < - timestamp('2020-10-01T00:00:00.000Z')", - } - } - ], - "etag": "BwWWja0YfJA=", - "version": 3 - } - - **YAML example:** - - :: - - bindings: - - members: - - user:mike@example.com - - group:admins@example.com - - domain:google.com - - serviceAccount:my-project-id@appspot.gserviceaccount.com - role: roles/resourcemanager.organizationAdmin - - members: - - user:eve@example.com - role: roles/resourcemanager.organizationViewer - condition: - title: expirable access - description: Does not grant access after Sep 2020 - expression: request.time < timestamp('2020-10-01T00:00:00.000Z') - etag: BwWWja0YfJA= - version: 3 - - For a description of IAM and its features, see the `IAM - documentation `__. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_http_options() - request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._SetIamPolicy._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = policy_pb2.Policy() - pb_resp = resp - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_set_iam_policy(resp) - return resp - - class _TestIamPermissions(_BaseArtifactRegistryRestTransport._BaseTestIamPermissions, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.TestIamPermissions") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: iam_policy_pb2.TestIamPermissionsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Call the test iam permissions method over HTTP. - - Args: - request (~.iam_policy_pb2.TestIamPermissionsRequest): - The request object. Request message for ``TestIamPermissions`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.iam_policy_pb2.TestIamPermissionsResponse: - Response message for ``TestIamPermissions`` method. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_http_options() - request, metadata = self._interceptor.pre_test_iam_permissions(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._TestIamPermissions._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = iam_policy_pb2.TestIamPermissionsResponse() - pb_resp = resp - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_test_iam_permissions(resp) - return resp - - class _UpdateFile(_BaseArtifactRegistryRestTransport._BaseUpdateFile, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateFile") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_file.UpdateFileRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_file.File: - r"""Call the update file method over HTTP. - - Args: - request (~.gda_file.UpdateFileRequest): - The request object. The request to update a file. - 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: - ~.gda_file.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_http_options() - request, metadata = self._interceptor.pre_update_file(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateFile._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_file.File() - pb_resp = gda_file.File.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_file(resp) - return resp - - class _UpdatePackage(_BaseArtifactRegistryRestTransport._BaseUpdatePackage, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdatePackage") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_package.UpdatePackageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_package.Package: - r"""Call the update package method over HTTP. - - Args: - request (~.gda_package.UpdatePackageRequest): - The request object. The request to update a package. - 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: - ~.gda_package.Package: - Packages are named collections of - versions. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_http_options() - request, metadata = self._interceptor.pre_update_package(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdatePackage._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_package.Package() - pb_resp = gda_package.Package.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_package(resp) - return resp - - class _UpdateProjectSettings(_BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateProjectSettings") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: settings.UpdateProjectSettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> settings.ProjectSettings: - r"""Call the update project settings method over HTTP. - - Args: - request (~.settings.UpdateProjectSettingsRequest): - The request object. Sets the settings of the project. - 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: - ~.settings.ProjectSettings: - The Artifact Registry settings that - apply to a Project. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_http_options() - request, metadata = self._interceptor.pre_update_project_settings(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateProjectSettings._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = settings.ProjectSettings() - pb_resp = settings.ProjectSettings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_project_settings(resp) - return resp - - class _UpdateRepository(_BaseArtifactRegistryRestTransport._BaseUpdateRepository, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateRepository") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_repository.UpdateRepositoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_repository.Repository: - r"""Call the update repository method over HTTP. - - Args: - request (~.gda_repository.UpdateRepositoryRequest): - The request object. The request to update a repository. - 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: - ~.gda_repository.Repository: - A Repository for storing artifacts - with a specific format. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_http_options() - request, metadata = self._interceptor.pre_update_repository(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateRepository._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_repository.Repository() - pb_resp = gda_repository.Repository.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_repository(resp) - return resp - - class _UpdateRule(_BaseArtifactRegistryRestTransport._BaseUpdateRule, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateRule") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_rule.UpdateRuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_rule.Rule: - r"""Call the update rule method over HTTP. - - Args: - request (~.gda_rule.UpdateRuleRequest): - The request object. The request to update a rule. - 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: - ~.gda_rule.Rule: - A rule defines the deny or allow - action of the operation it applies to - and the conditions required for the rule - to apply. You can set one rule for an - entire repository and one rule for each - package within. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_http_options() - request, metadata = self._interceptor.pre_update_rule(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateRule._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_rule.Rule() - pb_resp = gda_rule.Rule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_rule(resp) - return resp - - class _UpdateTag(_BaseArtifactRegistryRestTransport._BaseUpdateTag, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateTag") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_tag.UpdateTagRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_tag.Tag: - r"""Call the update tag method over HTTP. - - Args: - request (~.gda_tag.UpdateTagRequest): - The request object. The request to create or update a - tag. - 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: - ~.gda_tag.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_http_options() - request, metadata = self._interceptor.pre_update_tag(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateTag._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_tag.Tag() - pb_resp = gda_tag.Tag.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_tag(resp) - return resp - - class _UpdateVersion(_BaseArtifactRegistryRestTransport._BaseUpdateVersion, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateVersion") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_version.UpdateVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_version.Version: - r"""Call the update version method over HTTP. - - Args: - request (~.gda_version.UpdateVersionRequest): - The request object. The request to update a version. - 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: - ~.gda_version.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_http_options() - request, metadata = self._interceptor.pre_update_version(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateVersion._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_version.Version() - pb_resp = gda_version.Version.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_version(resp) - return resp - - class _UpdateVPCSCConfig(_BaseArtifactRegistryRestTransport._BaseUpdateVPCSCConfig, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateVPCSCConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_vpcsc_config.UpdateVPCSCConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_vpcsc_config.VPCSCConfig: - r"""Call the update vpcsc config method over HTTP. - - Args: - request (~.gda_vpcsc_config.UpdateVPCSCConfigRequest): - The request object. Sets the VPCSC config of the project. - 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: - ~.gda_vpcsc_config.VPCSCConfig: - The Artifact Registry VPC SC config - that apply to a Project. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateVPCSCConfig._get_http_options() - request, metadata = self._interceptor.pre_update_vpcsc_config(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateVPCSCConfig._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateVPCSCConfig._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateVPCSCConfig._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateVPCSCConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_vpcsc_config.VPCSCConfig() - pb_resp = gda_vpcsc_config.VPCSCConfig.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_vpcsc_config(resp) - return resp - - @property - def batch_delete_versions(self) -> Callable[ - [version.BatchDeleteVersionsRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._BatchDeleteVersions(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_attachment(self) -> Callable[ - [gda_attachment.CreateAttachmentRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateAttachment(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_repository(self) -> Callable[ - [gda_repository.CreateRepositoryRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateRepository(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_rule(self) -> Callable[ - [gda_rule.CreateRuleRequest], - gda_rule.Rule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateRule(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_tag(self) -> Callable[ - [gda_tag.CreateTagRequest], - gda_tag.Tag]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateTag(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_attachment(self) -> Callable[ - [attachment.DeleteAttachmentRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteAttachment(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_file(self) -> Callable[ - [file.DeleteFileRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteFile(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_package(self) -> Callable[ - [package.DeletePackageRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeletePackage(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_repository(self) -> Callable[ - [repository.DeleteRepositoryRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteRepository(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_rule(self) -> Callable[ - [rule.DeleteRuleRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteRule(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_tag(self) -> Callable[ - [tag.DeleteTagRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteTag(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_attachment(self) -> Callable[ - [attachment.GetAttachmentRequest], - attachment.Attachment]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetAttachment(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_docker_image(self) -> Callable[ - [artifact.GetDockerImageRequest], - artifact.DockerImage]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetDockerImage(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_file(self) -> Callable[ - [file.GetFileRequest], - file.File]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetFile(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_iam_policy(self) -> Callable[ - [iam_policy_pb2.GetIamPolicyRequest], - policy_pb2.Policy]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetIamPolicy(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_maven_artifact(self) -> Callable[ - [artifact.GetMavenArtifactRequest], - artifact.MavenArtifact]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetMavenArtifact(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_npm_package(self) -> Callable[ - [artifact.GetNpmPackageRequest], - artifact.NpmPackage]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetNpmPackage(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_package(self) -> Callable[ - [package.GetPackageRequest], - package.Package]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetPackage(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_project_settings(self) -> Callable[ - [settings.GetProjectSettingsRequest], - settings.ProjectSettings]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetProjectSettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_python_package(self) -> Callable[ - [artifact.GetPythonPackageRequest], - artifact.PythonPackage]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetPythonPackage(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_repository(self) -> Callable[ - [repository.GetRepositoryRequest], - repository.Repository]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetRepository(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_rule(self) -> Callable[ - [rule.GetRuleRequest], - rule.Rule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetRule(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_tag(self) -> Callable[ - [tag.GetTagRequest], - tag.Tag]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetTag(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - version.Version]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_vpcsc_config(self) -> Callable[ - [vpcsc_config.GetVPCSCConfigRequest], - vpcsc_config.VPCSCConfig]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetVPCSCConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def import_apt_artifacts(self) -> Callable[ - [apt_artifact.ImportAptArtifactsRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ImportAptArtifacts(self._session, self._host, self._interceptor) # type: ignore - - @property - def import_yum_artifacts(self) -> Callable[ - [yum_artifact.ImportYumArtifactsRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ImportYumArtifacts(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_attachments(self) -> Callable[ - [attachment.ListAttachmentsRequest], - attachment.ListAttachmentsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListAttachments(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_docker_images(self) -> Callable[ - [artifact.ListDockerImagesRequest], - artifact.ListDockerImagesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListDockerImages(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_files(self) -> Callable[ - [file.ListFilesRequest], - file.ListFilesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListFiles(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_maven_artifacts(self) -> Callable[ - [artifact.ListMavenArtifactsRequest], - artifact.ListMavenArtifactsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListMavenArtifacts(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_npm_packages(self) -> Callable[ - [artifact.ListNpmPackagesRequest], - artifact.ListNpmPackagesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListNpmPackages(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_packages(self) -> Callable[ - [package.ListPackagesRequest], - package.ListPackagesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListPackages(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_python_packages(self) -> Callable[ - [artifact.ListPythonPackagesRequest], - artifact.ListPythonPackagesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListPythonPackages(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_repositories(self) -> Callable[ - [repository.ListRepositoriesRequest], - repository.ListRepositoriesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListRepositories(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_rules(self) -> Callable[ - [rule.ListRulesRequest], - rule.ListRulesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListRules(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_tags(self) -> Callable[ - [tag.ListTagsRequest], - tag.ListTagsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListTags(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - version.ListVersionsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListVersions(self._session, self._host, self._interceptor) # type: ignore - - @property - def set_iam_policy(self) -> Callable[ - [iam_policy_pb2.SetIamPolicyRequest], - policy_pb2.Policy]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._SetIamPolicy(self._session, self._host, self._interceptor) # type: ignore - - @property - def test_iam_permissions(self) -> Callable[ - [iam_policy_pb2.TestIamPermissionsRequest], - iam_policy_pb2.TestIamPermissionsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._TestIamPermissions(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_file(self) -> Callable[ - [gda_file.UpdateFileRequest], - gda_file.File]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateFile(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_package(self) -> Callable[ - [gda_package.UpdatePackageRequest], - gda_package.Package]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdatePackage(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_project_settings(self) -> Callable[ - [settings.UpdateProjectSettingsRequest], - settings.ProjectSettings]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateProjectSettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_repository(self) -> Callable[ - [gda_repository.UpdateRepositoryRequest], - gda_repository.Repository]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateRepository(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_rule(self) -> Callable[ - [gda_rule.UpdateRuleRequest], - gda_rule.Rule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateRule(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_tag(self) -> Callable[ - [gda_tag.UpdateTagRequest], - gda_tag.Tag]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateTag(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_version(self) -> Callable[ - [gda_version.UpdateVersionRequest], - gda_version.Version]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_vpcsc_config(self) -> Callable[ - [gda_vpcsc_config.UpdateVPCSCConfigRequest], - gda_vpcsc_config.VPCSCConfig]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateVPCSCConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(_BaseArtifactRegistryRestTransport._BaseGetLocation, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetLocation") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetLocation._get_http_options() - request, metadata = self._interceptor.pre_get_location(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetLocation._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetLocation._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetLocation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - content = response.content.decode("utf-8") - resp = locations_pb2.Location() - resp = json_format.Parse(content, resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(_BaseArtifactRegistryRestTransport._BaseListLocations, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListLocations") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListLocations._get_http_options() - request, metadata = self._interceptor.pre_list_locations(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListLocations._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListLocations._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListLocations._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - content = response.content.decode("utf-8") - resp = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(content, resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def get_operation(self): - return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore - - class _GetOperation(_BaseArtifactRegistryRestTransport._BaseGetOperation, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetOperation") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: operations_pb2.GetOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - - r"""Call the get operation method over HTTP. - - Args: - request (operations_pb2.GetOperationRequest): - The request object 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: Response from GetOperation method. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetOperation._get_http_options() - request, metadata = self._interceptor.pre_get_operation(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetOperation._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetOperation._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetOperation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - content = response.content.decode("utf-8") - resp = operations_pb2.Operation() - resp = json_format.Parse(content, resp) - resp = self._interceptor.post_get_operation(resp) - return resp - - @property - def kind(self) -> str: - return "rest" - - def close(self): - self._session.close() - - -__all__=( - 'ArtifactRegistryRestTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest_base.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest_base.py deleted file mode 100644 index 8cacda89a510..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest_base.py +++ /dev/null @@ -1,2053 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import json # type: ignore -from google.api_core import path_template -from google.api_core import gapic_v1 - -from google.protobuf import json_format -from google.cloud.location import locations_pb2 # type: ignore -from .base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO - -import re -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union - - -from google.cloud.artifactregistry_v1.types import apt_artifact -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import attachment as gda_attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import file as gda_file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import package as gda_package -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 rule -from google.cloud.artifactregistry_v1.types import rule as gda_rule -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 -from google.cloud.artifactregistry_v1.types import version as gda_version -from google.cloud.artifactregistry_v1.types import vpcsc_config -from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config -from google.cloud.artifactregistry_v1.types import yum_artifact -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.longrunning import operations_pb2 # type: ignore - - -class _BaseArtifactRegistryRestTransport(ArtifactRegistryTransport): - """Base REST backend transport for ArtifactRegistry. - - Note: This class is not meant to be used directly. Use its sync and - async sub-classes instead. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends JSON representations of protocol buffers over HTTP/1.1 - """ - - def __init__(self, *, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[Any] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = 'https', - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[Any]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) - if maybe_url_match is None: - raise ValueError(f"Unexpected hostname structure: {host}") # pragma: NO COVER - - url_match_items = maybe_url_match.groupdict() - - host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host - - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience - ) - - class _BaseBatchDeleteVersions: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/versions:batchDelete', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = version.BatchDeleteVersionsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseBatchDeleteVersions._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateAttachment: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "attachmentId" : "", } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/attachments', - 'body': 'attachment', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_attachment.CreateAttachmentRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateRepository: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "repositoryId" : "", } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/repositories', - 'body': 'repository', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_repository.CreateRepositoryRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseCreateRepository._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateRule: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/rules', - 'body': 'rule', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_rule.CreateRuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseCreateRule._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateTag: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/tags', - 'body': 'tag', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_tag.CreateTagRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteAttachment: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/attachments/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = attachment.DeleteAttachmentRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteFile: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/files/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = file.DeleteFileRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseDeleteFile._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeletePackage: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/packages/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = package.DeletePackageRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseDeletePackage._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteRepository: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = repository.DeleteRepositoryRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteRule: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/rules/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = rule.DeleteRuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseDeleteRule._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteTag: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = tag.DeleteTagRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteVersion: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = version.DeleteVersionRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetAttachment: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/attachments/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = attachment.GetAttachmentRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetAttachment._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetDockerImage: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/dockerImages/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = artifact.GetDockerImageRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetDockerImage._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetFile: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/files/**}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = file.GetFileRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetFile._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetIamPolicy: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{resource=projects/*/locations/*/repositories/*}:getIamPolicy', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = request - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetMavenArtifact: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/mavenArtifacts/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = artifact.GetMavenArtifactRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetMavenArtifact._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetNpmPackage: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/npmPackages/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = artifact.GetNpmPackageRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetNpmPackage._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetPackage: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/packages/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = package.GetPackageRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetPackage._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetProjectSettings: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/projectSettings}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = settings.GetProjectSettingsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetPythonPackage: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/pythonPackages/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = artifact.GetPythonPackageRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetPythonPackage._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetRepository: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = repository.GetRepositoryRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetRepository._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetRule: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/rules/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = rule.GetRuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetRule._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetTag: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = tag.GetTagRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetVersion: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = version.GetVersionRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetVPCSCConfig: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/vpcscConfig}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = vpcsc_config.GetVPCSCConfigRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetVPCSCConfig._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseImportAptArtifacts: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/aptArtifacts:import', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = apt_artifact.ImportAptArtifactsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseImportYumArtifacts: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/yumArtifacts:import', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = yum_artifact.ImportYumArtifactsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListAttachments: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/attachments', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = attachment.ListAttachmentsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListAttachments._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListDockerImages: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/dockerImages', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = artifact.ListDockerImagesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListDockerImages._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListFiles: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/files', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = file.ListFilesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListFiles._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListMavenArtifacts: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/mavenArtifacts', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = artifact.ListMavenArtifactsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListMavenArtifacts._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListNpmPackages: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/npmPackages', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = artifact.ListNpmPackagesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListNpmPackages._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListPackages: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/packages', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = package.ListPackagesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListPackages._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListPythonPackages: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/pythonPackages', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = artifact.ListPythonPackagesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListPythonPackages._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListRepositories: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/repositories', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = repository.ListRepositoriesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListRepositories._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListRules: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*}/rules', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = rule.ListRulesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListRules._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListTags: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/tags', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = tag.ListTagsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListVersions: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/versions', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = version.ListVersionsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseSetIamPolicy: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{resource=projects/*/locations/*/repositories/*}:setIamPolicy', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = request - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseTestIamPermissions: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{resource=projects/*/locations/*/repositories/*}:testIamPermissions', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = request - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateFile: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask" : {}, } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{file.name=projects/*/locations/*/repositories/*/files/*}', - 'body': 'file', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_file.UpdateFileRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseUpdateFile._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdatePackage: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{package.name=projects/*/locations/*/repositories/*/packages/*}', - 'body': 'package', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_package.UpdatePackageRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateProjectSettings: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{project_settings.name=projects/*/projectSettings}', - 'body': 'project_settings', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = settings.UpdateProjectSettingsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateRepository: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{repository.name=projects/*/locations/*/repositories/*}', - 'body': 'repository', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_repository.UpdateRepositoryRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateRule: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{rule.name=projects/*/locations/*/repositories/*/rules/*}', - 'body': 'rule', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_rule.UpdateRuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateTag: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{tag.name=projects/*/locations/*/repositories/*/packages/*/tags/*}', - 'body': 'tag', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_tag.UpdateTagRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateVersion: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{version.name=projects/*/locations/*/repositories/*/packages/*/versions/*}', - 'body': 'version', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_version.UpdateVersionRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateVPCSCConfig: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{vpcsc_config.name=projects/*/locations/*/vpcscConfig}', - 'body': 'vpcsc_config', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_vpcsc_config.UpdateVPCSCConfigRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetLocation: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - return query_params - - class _BaseListLocations: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*}/locations', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - return query_params - - class _BaseGetOperation: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - return query_params - - -__all__=( - '_BaseArtifactRegistryRestTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/__init__.py deleted file mode 100644 index 7603e27004dc..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/__init__.py +++ /dev/null @@ -1,228 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 .apt_artifact import ( - AptArtifact, - ImportAptArtifactsErrorInfo, - ImportAptArtifactsGcsSource, - ImportAptArtifactsMetadata, - ImportAptArtifactsRequest, - ImportAptArtifactsResponse, -) -from .artifact import ( - DockerImage, - GetDockerImageRequest, - GetMavenArtifactRequest, - GetNpmPackageRequest, - GetPythonPackageRequest, - ListDockerImagesRequest, - ListDockerImagesResponse, - ListMavenArtifactsRequest, - ListMavenArtifactsResponse, - ListNpmPackagesRequest, - ListNpmPackagesResponse, - ListPythonPackagesRequest, - ListPythonPackagesResponse, - MavenArtifact, - NpmPackage, - PythonPackage, -) -from .attachment import ( - Attachment, - CreateAttachmentRequest, - DeleteAttachmentRequest, - GetAttachmentRequest, - ListAttachmentsRequest, - ListAttachmentsResponse, -) -from .file import ( - DeleteFileRequest, - File, - GetFileRequest, - Hash, - ListFilesRequest, - ListFilesResponse, - UpdateFileRequest, -) -from .generic import ( - GenericArtifact, -) -from .package import ( - DeletePackageRequest, - GetPackageRequest, - ListPackagesRequest, - ListPackagesResponse, - Package, - UpdatePackageRequest, -) -from .repository import ( - CleanupPolicy, - CleanupPolicyCondition, - CleanupPolicyMostRecentVersions, - CreateRepositoryRequest, - DeleteRepositoryRequest, - GetRepositoryRequest, - ListRepositoriesRequest, - ListRepositoriesResponse, - RemoteRepositoryConfig, - Repository, - UpdateRepositoryRequest, - UpstreamPolicy, - VirtualRepositoryConfig, -) -from .rule import ( - CreateRuleRequest, - DeleteRuleRequest, - GetRuleRequest, - ListRulesRequest, - ListRulesResponse, - Rule, - UpdateRuleRequest, -) -from .service import ( - OperationMetadata, -) -from .settings import ( - GetProjectSettingsRequest, - ProjectSettings, - UpdateProjectSettingsRequest, -) -from .tag import ( - CreateTagRequest, - DeleteTagRequest, - GetTagRequest, - ListTagsRequest, - ListTagsResponse, - Tag, - UpdateTagRequest, -) -from .version import ( - BatchDeleteVersionsMetadata, - BatchDeleteVersionsRequest, - DeleteVersionRequest, - GetVersionRequest, - ListVersionsRequest, - ListVersionsResponse, - UpdateVersionRequest, - Version, - VersionView, -) -from .vpcsc_config import ( - GetVPCSCConfigRequest, - UpdateVPCSCConfigRequest, - VPCSCConfig, -) -from .yum_artifact import ( - ImportYumArtifactsErrorInfo, - ImportYumArtifactsGcsSource, - ImportYumArtifactsMetadata, - ImportYumArtifactsRequest, - ImportYumArtifactsResponse, - YumArtifact, -) - -__all__ = ( - 'AptArtifact', - 'ImportAptArtifactsErrorInfo', - 'ImportAptArtifactsGcsSource', - 'ImportAptArtifactsMetadata', - 'ImportAptArtifactsRequest', - 'ImportAptArtifactsResponse', - 'DockerImage', - 'GetDockerImageRequest', - 'GetMavenArtifactRequest', - 'GetNpmPackageRequest', - 'GetPythonPackageRequest', - 'ListDockerImagesRequest', - 'ListDockerImagesResponse', - 'ListMavenArtifactsRequest', - 'ListMavenArtifactsResponse', - 'ListNpmPackagesRequest', - 'ListNpmPackagesResponse', - 'ListPythonPackagesRequest', - 'ListPythonPackagesResponse', - 'MavenArtifact', - 'NpmPackage', - 'PythonPackage', - 'Attachment', - 'CreateAttachmentRequest', - 'DeleteAttachmentRequest', - 'GetAttachmentRequest', - 'ListAttachmentsRequest', - 'ListAttachmentsResponse', - 'DeleteFileRequest', - 'File', - 'GetFileRequest', - 'Hash', - 'ListFilesRequest', - 'ListFilesResponse', - 'UpdateFileRequest', - 'GenericArtifact', - 'DeletePackageRequest', - 'GetPackageRequest', - 'ListPackagesRequest', - 'ListPackagesResponse', - 'Package', - 'UpdatePackageRequest', - 'CleanupPolicy', - 'CleanupPolicyCondition', - 'CleanupPolicyMostRecentVersions', - 'CreateRepositoryRequest', - 'DeleteRepositoryRequest', - 'GetRepositoryRequest', - 'ListRepositoriesRequest', - 'ListRepositoriesResponse', - 'RemoteRepositoryConfig', - 'Repository', - 'UpdateRepositoryRequest', - 'UpstreamPolicy', - 'VirtualRepositoryConfig', - 'CreateRuleRequest', - 'DeleteRuleRequest', - 'GetRuleRequest', - 'ListRulesRequest', - 'ListRulesResponse', - 'Rule', - 'UpdateRuleRequest', - 'OperationMetadata', - 'GetProjectSettingsRequest', - 'ProjectSettings', - 'UpdateProjectSettingsRequest', - 'CreateTagRequest', - 'DeleteTagRequest', - 'GetTagRequest', - 'ListTagsRequest', - 'ListTagsResponse', - 'Tag', - 'UpdateTagRequest', - 'BatchDeleteVersionsMetadata', - 'BatchDeleteVersionsRequest', - 'DeleteVersionRequest', - 'GetVersionRequest', - 'ListVersionsRequest', - 'ListVersionsResponse', - 'UpdateVersionRequest', - 'Version', - 'VersionView', - 'GetVPCSCConfigRequest', - 'UpdateVPCSCConfigRequest', - 'VPCSCConfig', - 'ImportYumArtifactsErrorInfo', - 'ImportYumArtifactsGcsSource', - 'ImportYumArtifactsMetadata', - 'ImportYumArtifactsRequest', - 'ImportYumArtifactsResponse', - 'YumArtifact', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/apt_artifact.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/apt_artifact.py deleted file mode 100644 index fa15b859d922..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/apt_artifact.py +++ /dev/null @@ -1,210 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.rpc import status_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'AptArtifact', - 'ImportAptArtifactsGcsSource', - 'ImportAptArtifactsRequest', - 'ImportAptArtifactsErrorInfo', - 'ImportAptArtifactsResponse', - 'ImportAptArtifactsMetadata', - }, -) - - -class AptArtifact(proto.Message): - r"""A detailed representation of an Apt artifact. Information in - the record is derived from the archive's control file. See - https://www.debian.org/doc/debian-policy/ch-controlfields.html - - Attributes: - name (str): - Output only. The Artifact Registry resource - name of the artifact. - package_name (str): - Output only. The Apt package name of the - artifact. - package_type (google.cloud.artifactregistry_v1.types.AptArtifact.PackageType): - Output only. An artifact is a binary or - source package. - architecture (str): - Output only. Operating system architecture of - the artifact. - component (str): - Output only. Repository component of the - artifact. - control_file (bytes): - Output only. Contents of the artifact's - control metadata file. - """ - class PackageType(proto.Enum): - r"""Package type is either binary or source. - - Values: - PACKAGE_TYPE_UNSPECIFIED (0): - Package type is not specified. - BINARY (1): - Binary package. - SOURCE (2): - Source package. - """ - PACKAGE_TYPE_UNSPECIFIED = 0 - BINARY = 1 - SOURCE = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - package_name: str = proto.Field( - proto.STRING, - number=2, - ) - package_type: PackageType = proto.Field( - proto.ENUM, - number=3, - enum=PackageType, - ) - architecture: str = proto.Field( - proto.STRING, - number=4, - ) - component: str = proto.Field( - proto.STRING, - number=5, - ) - control_file: bytes = proto.Field( - proto.BYTES, - number=6, - ) - - -class ImportAptArtifactsGcsSource(proto.Message): - r"""Google Cloud Storage location where the artifacts currently - reside. - - Attributes: - uris (MutableSequence[str]): - Cloud Storage paths URI (e.g., gs://my_bucket//my_object). - use_wildcards (bool): - Supports URI wildcards for matching multiple - objects from a single URI. - """ - - uris: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - use_wildcards: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class ImportAptArtifactsRequest(proto.Message): - r"""The request to import new apt artifacts. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.artifactregistry_v1.types.ImportAptArtifactsGcsSource): - Google Cloud Storage location where input - content is located. - - This field is a member of `oneof`_ ``source``. - parent (str): - The name of the parent resource where the - artifacts will be imported. - """ - - gcs_source: 'ImportAptArtifactsGcsSource' = proto.Field( - proto.MESSAGE, - number=2, - oneof='source', - message='ImportAptArtifactsGcsSource', - ) - parent: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ImportAptArtifactsErrorInfo(proto.Message): - r"""Error information explaining why a package was not imported. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.artifactregistry_v1.types.ImportAptArtifactsGcsSource): - Google Cloud Storage location requested. - - This field is a member of `oneof`_ ``source``. - error (google.rpc.status_pb2.Status): - The detailed error status. - """ - - gcs_source: 'ImportAptArtifactsGcsSource' = proto.Field( - proto.MESSAGE, - number=1, - oneof='source', - message='ImportAptArtifactsGcsSource', - ) - error: status_pb2.Status = proto.Field( - proto.MESSAGE, - number=2, - message=status_pb2.Status, - ) - - -class ImportAptArtifactsResponse(proto.Message): - r"""The response message from importing APT artifacts. - - Attributes: - apt_artifacts (MutableSequence[google.cloud.artifactregistry_v1.types.AptArtifact]): - The Apt artifacts imported. - errors (MutableSequence[google.cloud.artifactregistry_v1.types.ImportAptArtifactsErrorInfo]): - Detailed error info for packages that were - not imported. - """ - - apt_artifacts: MutableSequence['AptArtifact'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='AptArtifact', - ) - errors: MutableSequence['ImportAptArtifactsErrorInfo'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='ImportAptArtifactsErrorInfo', - ) - - -class ImportAptArtifactsMetadata(proto.Message): - r"""The operation metadata for importing artifacts. - """ - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/artifact.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/artifact.py deleted file mode 100644 index 5af9d5bb3005..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/artifact.py +++ /dev/null @@ -1,595 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'DockerImage', - 'ListDockerImagesRequest', - 'ListDockerImagesResponse', - 'GetDockerImageRequest', - 'MavenArtifact', - 'ListMavenArtifactsRequest', - 'ListMavenArtifactsResponse', - 'GetMavenArtifactRequest', - 'NpmPackage', - 'ListNpmPackagesRequest', - 'ListNpmPackagesResponse', - 'GetNpmPackageRequest', - 'PythonPackage', - 'ListPythonPackagesRequest', - 'ListPythonPackagesResponse', - 'GetPythonPackageRequest', - }, -) - - -class DockerImage(proto.Message): - r"""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 - - Attributes: - name (str): - Required. registry_location, project_id, repository_name and - image id forms a unique image - name:\ ``projects//locations//repository//dockerImages/``. - For example, - "projects/test-project/locations/us-west4/repositories/test-repo/dockerImages/ - nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf", - where "us-west4" is the registry_location, "test-project" is - the project_id, "test-repo" is the repository_name and - "nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf" - is the image's digest. - uri (str): - Required. URL to access the image. - Example: - - us-west4-docker.pkg.dev/test-project/test-repo/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf - tags (MutableSequence[str]): - Tags attached to this image. - image_size_bytes (int): - Calculated size of the image. - This field is returned as the - 'metadata.imageSizeBytes' field in the Version - resource. - upload_time (google.protobuf.timestamp_pb2.Timestamp): - Time the image was uploaded. - media_type (str): - Media type of this image, e.g. - "application/vnd.docker.distribution.manifest.v2+json". - This field is returned as the - 'metadata.mediaType' field in the Version - resource. - build_time (google.protobuf.timestamp_pb2.Timestamp): - The time this image was built. - This field is returned as the - 'metadata.buildTime' field in the Version - resource. - 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( - proto.STRING, - number=1, - ) - uri: str = proto.Field( - proto.STRING, - number=2, - ) - tags: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - image_size_bytes: int = proto.Field( - proto.INT64, - number=4, - ) - upload_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - media_type: str = proto.Field( - proto.STRING, - number=6, - ) - build_time: timestamp_pb2.Timestamp = proto.Field( - 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): - r"""The request to list docker images. - - Attributes: - parent (str): - Required. The name of the parent resource - whose docker images will be listed. - page_size (int): - The maximum number of artifacts to return. - Maximum page size is 1,000. - 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( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - order_by: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListDockerImagesResponse(proto.Message): - r"""The response from listing docker images. - - Attributes: - docker_images (MutableSequence[google.cloud.artifactregistry_v1.types.DockerImage]): - The docker images 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 - - docker_images: MutableSequence['DockerImage'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='DockerImage', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetDockerImageRequest(proto.Message): - r"""The request to get docker images. - - Attributes: - name (str): - Required. The name of the docker images. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -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. - Maximum page size is 1,000. - 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. - Maximum page size is 1,000. - 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. - Maximum page size is 1,000. - 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/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/file.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/file.py deleted file mode 100644 index 8624425966f0..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/file.py +++ /dev/null @@ -1,320 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'Hash', - 'File', - 'ListFilesRequest', - 'ListFilesResponse', - 'GetFileRequest', - 'DeleteFileRequest', - 'UpdateFileRequest', - }, -) - - -class Hash(proto.Message): - r"""A hash of file content. - - Attributes: - type_ (google.cloud.artifactregistry_v1.types.Hash.HashType): - The algorithm used to compute the hash value. - value (bytes): - The hash value. - """ - class HashType(proto.Enum): - r"""The algorithm used to compute the hash. - - Values: - HASH_TYPE_UNSPECIFIED (0): - Unspecified. - SHA256 (1): - SHA256 hash. - MD5 (2): - MD5 hash. - """ - HASH_TYPE_UNSPECIFIED = 0 - SHA256 = 1 - MD5 = 2 - - type_: HashType = proto.Field( - proto.ENUM, - number=1, - enum=HashType, - ) - value: bytes = proto.Field( - proto.BYTES, - number=2, - ) - - -class File(proto.Message): - r"""Files store content that is potentially associated with - Packages or Versions. - - Attributes: - name (str): - The name of the file, for example: - ``projects/p1/locations/us-central1/repositories/repo1/files/a%2Fb%2Fc.txt``. - If the file ID part contains slashes, they are escaped. - size_bytes (int): - The size of the File in bytes. - hashes (MutableSequence[google.cloud.artifactregistry_v1.types.Hash]): - The hashes of the file content. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time when the File was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - 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. - annotations (MutableMapping[str, str]): - Optional. Client specified annotations. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - size_bytes: int = proto.Field( - proto.INT64, - number=3, - ) - hashes: MutableSequence['Hash'] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message='Hash', - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - owner: str = proto.Field( - proto.STRING, - number=7, - ) - fetch_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - annotations: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=9, - ) - - -class ListFilesRequest(proto.Message): - r"""The request to list files. - - Attributes: - parent (str): - 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. - Filter rules are case insensitive. The fields eligible for - filtering are: - - - ``name`` - - ``owner`` - - ``annotations`` - - Examples of using a filter: - - To filter the results of your request to files with the name - ``my_file.txt`` in project ``my-project`` in the - ``us-central`` region, in repository ``my-repo``, append the - following filter expression to your request: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/files/my-file.txt"`` - - You can also use wildcards to match any number of characters - before or after the value: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/files/my-*"`` - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/files/*file.txt"`` - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/files/*file*"`` - - To filter the results of your request to files owned by the - version ``1.0`` in package ``pkg1``, append the following - filter expression to your request: - - - ``owner="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/1.0"`` - - To filter the results of your request to files with the - annotation key-value pair [``external_link``: - ``external_link_value``], append the following filter - expression to your request: - - - ``"annotations.external_link:external_link_value"`` - - To filter just for a specific annotation key - ``external_link``, append the following filter expression to - your request: - - - ``"annotations.external_link"`` - - If the annotation key or value contains special characters, - you can escape them by surrounding the value with backticks. - For example, to filter the results of your request to files - with the annotation key-value pair - [``external.link``:``https://example.com/my-file``], append - the following filter expression to your request: - - - :literal:`"annotations.`external.link`:`https://example.com/my-file`"` - - You can also filter with annotations with a wildcard to - match any number of characters before or after the value: - - - :literal:`"annotations.*_link:`*example.com*`"` - page_size (int): - The maximum number of files to return. - Maximum page size is 1,000. - 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( - proto.STRING, - number=1, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListFilesResponse(proto.Message): - r"""The response from listing files. - - Attributes: - files (MutableSequence[google.cloud.artifactregistry_v1.types.File]): - The files returned. - next_page_token (str): - The token to retrieve the next page of files, - or empty if there are no more files to return. - """ - - @property - def raw_page(self): - return self - - files: MutableSequence['File'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='File', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetFileRequest(proto.Message): - r"""The request to retrieve a file. - - Attributes: - name (str): - Required. The name of the file to retrieve. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeleteFileRequest(proto.Message): - r"""The request to delete a file. - - Attributes: - name (str): - Required. The name of the file to delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateFileRequest(proto.Message): - r"""The request to update a file. - - Attributes: - file (google.cloud.artifactregistry_v1.types.File): - Required. The File that replaces the resource - on the server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - file: 'File' = proto.Field( - proto.MESSAGE, - number=1, - message='File', - ) - 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/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/package.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/package.py deleted file mode 100644 index 368f3d6e99e3..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/package.py +++ /dev/null @@ -1,255 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'Package', - 'ListPackagesRequest', - 'ListPackagesResponse', - 'GetPackageRequest', - 'DeletePackageRequest', - 'UpdatePackageRequest', - }, -) - - -class Package(proto.Message): - r"""Packages are named collections of versions. - - Attributes: - name (str): - The name of the package, for example: - ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1``. - If the package ID part contains slashes, the slashes are - escaped. - display_name (str): - The display name of the package. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the package was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the package was last updated. - This includes publishing a new version of the - package. - annotations (MutableMapping[str, str]): - Optional. Client specified annotations. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - annotations: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=7, - ) - - -class ListPackagesRequest(proto.Message): - r"""The request to list packages. - - Attributes: - parent (str): - Required. The name of the parent resource - whose packages will be listed. - page_size (int): - The maximum number of packages to return. - Maximum page size is 1,000. - page_token (str): - The next_page_token value returned from a previous list - request, if any. - filter (str): - Optional. An expression for filtering the results of the - request. Filter rules are case insensitive. The fields - eligible for filtering are: - - - ``name`` - - ``annotations`` - - Examples of using a filter: - - To filter the results of your request to packages with the - name ``my-package`` in project ``my-project`` in the - ``us-central`` region, in repository ``my-repo``, append the - following filter expression to your request: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package"`` - - You can also use wildcards to match any number of characters - before or after the value: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-*"`` - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/*package"`` - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/*pack*"`` - - To filter the results of your request to packages with the - annotation key-value pair [``external_link``: - ``external_link_value``], append the following filter - expression to your request": - - - ``"annotations.external_link:external_link_value"`` - - To filter the results just for a specific annotation key - ``external_link``, append the following filter expression to - your request: - - - ``"annotations.external_link"`` - - If the annotation key or value contains special characters, - you can escape them by surrounding the value with backticks. - For example, to filter the results of your request to - packages with the annotation key-value pair - [``external.link``:``https://example.com/my-package``], - append the following filter expression to your request: - - - :literal:`"annotations.`external.link`:`https://example.com/my-package`"` - - You can also filter with annotations with a wildcard to - match any number of characters before or after the value: - - - :literal:`"annotations.*_link:`*example.com*`"` - order_by (str): - Optional. The field to order the results by. - """ - - 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, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListPackagesResponse(proto.Message): - r"""The response from listing packages. - - Attributes: - packages (MutableSequence[google.cloud.artifactregistry_v1.types.Package]): - The packages returned. - next_page_token (str): - The token to retrieve the next page of - packages, or empty if there are no more packages - to return. - """ - - @property - def raw_page(self): - return self - - packages: MutableSequence['Package'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Package', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetPackageRequest(proto.Message): - r"""The request to retrieve a package. - - Attributes: - name (str): - Required. The name of the package to - retrieve. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeletePackageRequest(proto.Message): - r"""The request to delete a package. - - Attributes: - name (str): - Required. The name of the package to delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdatePackageRequest(proto.Message): - r"""The request to update a package. - - Attributes: - package (google.cloud.artifactregistry_v1.types.Package): - The package that replaces the resource on the - server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - package: 'Package' = proto.Field( - proto.MESSAGE, - number=1, - message='Package', - ) - 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/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/repository.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/repository.py deleted file mode 100644 index 49a098e08c5b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/repository.py +++ /dev/null @@ -1,1437 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'UpstreamPolicy', - 'CleanupPolicyCondition', - 'CleanupPolicyMostRecentVersions', - 'CleanupPolicy', - 'VirtualRepositoryConfig', - 'RemoteRepositoryConfig', - 'Repository', - 'ListRepositoriesRequest', - 'ListRepositoriesResponse', - 'GetRepositoryRequest', - 'CreateRepositoryRequest', - 'UpdateRepositoryRequest', - 'DeleteRepositoryRequest', - }, -) - - -class UpstreamPolicy(proto.Message): - r"""Artifact policy configuration for the repository contents. - - Attributes: - id (str): - The user-provided ID of the upstream policy. - repository (str): - A reference to the repository resource, for example: - ``projects/p1/locations/us-central1/repositories/repo1``. - priority (int): - Entries with a greater priority value take - precedence in the pull order. - """ - - id: str = proto.Field( - proto.STRING, - number=1, - ) - repository: str = proto.Field( - proto.STRING, - number=2, - ) - priority: int = proto.Field( - proto.INT32, - number=3, - ) - - -class CleanupPolicyCondition(proto.Message): - r"""CleanupPolicyCondition is a set of conditions attached to a - CleanupPolicy. If multiple entries are set, all must be - satisfied for the condition to be satisfied. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - tag_state (google.cloud.artifactregistry_v1.types.CleanupPolicyCondition.TagState): - Match versions by tag status. - - This field is a member of `oneof`_ ``_tag_state``. - tag_prefixes (MutableSequence[str]): - Match versions by tag prefix. Applied on any - prefix match. - version_name_prefixes (MutableSequence[str]): - Match versions by version name prefix. - Applied on any prefix match. - package_name_prefixes (MutableSequence[str]): - Match versions by package prefix. Applied on - any prefix match. - older_than (google.protobuf.duration_pb2.Duration): - Match versions older than a duration. - - This field is a member of `oneof`_ ``_older_than``. - newer_than (google.protobuf.duration_pb2.Duration): - Match versions newer than a duration. - - This field is a member of `oneof`_ ``_newer_than``. - """ - class TagState(proto.Enum): - r"""Statuses applying to versions. - - Values: - TAG_STATE_UNSPECIFIED (0): - Tag status not specified. - TAGGED (1): - Applies to tagged versions only. - UNTAGGED (2): - Applies to untagged versions only. - ANY (3): - Applies to all versions. - """ - TAG_STATE_UNSPECIFIED = 0 - TAGGED = 1 - UNTAGGED = 2 - ANY = 3 - - tag_state: TagState = proto.Field( - proto.ENUM, - number=2, - optional=True, - enum=TagState, - ) - tag_prefixes: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - version_name_prefixes: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=4, - ) - package_name_prefixes: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=5, - ) - older_than: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=6, - optional=True, - message=duration_pb2.Duration, - ) - newer_than: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=7, - optional=True, - message=duration_pb2.Duration, - ) - - -class CleanupPolicyMostRecentVersions(proto.Message): - r"""CleanupPolicyMostRecentVersions is an alternate condition of - a CleanupPolicy for retaining a minimum number of versions. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - package_name_prefixes (MutableSequence[str]): - List of package name prefixes that will apply - this rule. - keep_count (int): - Minimum number of versions to keep. - - This field is a member of `oneof`_ ``_keep_count``. - """ - - package_name_prefixes: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - keep_count: int = proto.Field( - proto.INT32, - number=2, - optional=True, - ) - - -class CleanupPolicy(proto.Message): - r"""Artifact policy configuration for repository cleanup - policies. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - condition (google.cloud.artifactregistry_v1.types.CleanupPolicyCondition): - Policy condition for matching versions. - - This field is a member of `oneof`_ ``condition_type``. - most_recent_versions (google.cloud.artifactregistry_v1.types.CleanupPolicyMostRecentVersions): - Policy condition for retaining a minimum - number of versions. May only be specified with a - Keep action. - - This field is a member of `oneof`_ ``condition_type``. - id (str): - The user-provided ID of the cleanup policy. - action (google.cloud.artifactregistry_v1.types.CleanupPolicy.Action): - Policy action. - """ - class Action(proto.Enum): - r"""Action type for a cleanup policy. - - Values: - ACTION_UNSPECIFIED (0): - Action not specified. - DELETE (1): - Delete action. - KEEP (2): - Keep action. - """ - ACTION_UNSPECIFIED = 0 - DELETE = 1 - KEEP = 2 - - condition: 'CleanupPolicyCondition' = proto.Field( - proto.MESSAGE, - number=2, - oneof='condition_type', - message='CleanupPolicyCondition', - ) - most_recent_versions: 'CleanupPolicyMostRecentVersions' = proto.Field( - proto.MESSAGE, - number=4, - oneof='condition_type', - message='CleanupPolicyMostRecentVersions', - ) - id: str = proto.Field( - proto.STRING, - number=1, - ) - action: Action = proto.Field( - proto.ENUM, - number=3, - enum=Action, - ) - - -class VirtualRepositoryConfig(proto.Message): - r"""Virtual repository configuration. - - Attributes: - upstream_policies (MutableSequence[google.cloud.artifactregistry_v1.types.UpstreamPolicy]): - Policies that configure the upstream - artifacts distributed by the Virtual Repository. - Upstream policies cannot be set on a standard - repository. - """ - - upstream_policies: MutableSequence['UpstreamPolicy'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='UpstreamPolicy', - ) - - -class RemoteRepositoryConfig(proto.Message): - r"""Remote repository configuration. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - docker_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.DockerRepository): - Specific settings for a Docker remote - repository. - - This field is a member of `oneof`_ ``remote_source``. - maven_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.MavenRepository): - Specific settings for a Maven remote - repository. - - This field is a member of `oneof`_ ``remote_source``. - npm_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.NpmRepository): - Specific settings for an Npm remote - repository. - - This field is a member of `oneof`_ ``remote_source``. - python_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.PythonRepository): - Specific settings for a Python remote - repository. - - This field is a member of `oneof`_ ``remote_source``. - apt_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.AptRepository): - Specific settings for an Apt remote - repository. - - This field is a member of `oneof`_ ``remote_source``. - yum_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.YumRepository): - Specific settings for a Yum remote - repository. - - This field is a member of `oneof`_ ``remote_source``. - common_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.CommonRemoteRepository): - Common remote repository settings. - Used as the remote repository upstream URL. - - This field is a member of `oneof`_ ``remote_source``. - description (str): - The description of the remote source. - upstream_credentials (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.UpstreamCredentials): - Optional. The credentials used to access the - remote repository. - disable_upstream_validation (bool): - Input only. A create/update remote repo - option to avoid making a HEAD/GET request to - validate a remote repo and any supplied upstream - credentials. - """ - - class UpstreamCredentials(proto.Message): - r"""The credentials to access the remote repository. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - username_password_credentials (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.UpstreamCredentials.UsernamePasswordCredentials): - Use username and password to access the - remote repository. - - This field is a member of `oneof`_ ``credentials``. - """ - - class UsernamePasswordCredentials(proto.Message): - r"""Username and password credentials. - - Attributes: - username (str): - The username to access the remote repository. - password_secret_version (str): - The Secret Manager key version that holds the password to - access the remote repository. Must be in the format of - ``projects/{project}/secrets/{secret}/versions/{version}``. - """ - - username: str = proto.Field( - proto.STRING, - number=1, - ) - password_secret_version: str = proto.Field( - proto.STRING, - number=2, - ) - - username_password_credentials: 'RemoteRepositoryConfig.UpstreamCredentials.UsernamePasswordCredentials' = proto.Field( - proto.MESSAGE, - number=1, - oneof='credentials', - message='RemoteRepositoryConfig.UpstreamCredentials.UsernamePasswordCredentials', - ) - - class DockerRepository(proto.Message): - r"""Configuration for a Docker remote repository. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - public_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.DockerRepository.PublicRepository): - One of the publicly available Docker - repositories supported by Artifact Registry. - - This field is a member of `oneof`_ ``upstream``. - custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.DockerRepository.CustomRepository): - Customer-specified remote repository. - - This field is a member of `oneof`_ ``upstream``. - """ - class PublicRepository(proto.Enum): - r"""Predefined list of publicly available Docker repositories - like Docker Hub. - - Values: - PUBLIC_REPOSITORY_UNSPECIFIED (0): - Unspecified repository. - DOCKER_HUB (1): - Docker Hub. - """ - PUBLIC_REPOSITORY_UNSPECIFIED = 0 - DOCKER_HUB = 1 - - class CustomRepository(proto.Message): - r"""Customer-specified publicly available remote repository. - - Attributes: - uri (str): - An http/https uri reference to the custom - remote repository, for ex: - "https://registry-1.docker.io". - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - public_repository: 'RemoteRepositoryConfig.DockerRepository.PublicRepository' = proto.Field( - proto.ENUM, - number=1, - oneof='upstream', - enum='RemoteRepositoryConfig.DockerRepository.PublicRepository', - ) - custom_repository: 'RemoteRepositoryConfig.DockerRepository.CustomRepository' = proto.Field( - proto.MESSAGE, - number=3, - oneof='upstream', - message='RemoteRepositoryConfig.DockerRepository.CustomRepository', - ) - - class MavenRepository(proto.Message): - r"""Configuration for a Maven remote repository. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - public_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.MavenRepository.PublicRepository): - One of the publicly available Maven - repositories supported by Artifact Registry. - - This field is a member of `oneof`_ ``upstream``. - custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.MavenRepository.CustomRepository): - Customer-specified remote repository. - - This field is a member of `oneof`_ ``upstream``. - """ - class PublicRepository(proto.Enum): - r"""Predefined list of publicly available Maven repositories like - Maven Central. - - Values: - PUBLIC_REPOSITORY_UNSPECIFIED (0): - Unspecified repository. - MAVEN_CENTRAL (1): - Maven Central. - """ - PUBLIC_REPOSITORY_UNSPECIFIED = 0 - MAVEN_CENTRAL = 1 - - class CustomRepository(proto.Message): - r"""Customer-specified publicly available remote repository. - - Attributes: - uri (str): - An http/https uri reference to the upstream - remote repository, for ex: - "https://my.maven.registry/". - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - public_repository: 'RemoteRepositoryConfig.MavenRepository.PublicRepository' = proto.Field( - proto.ENUM, - number=1, - oneof='upstream', - enum='RemoteRepositoryConfig.MavenRepository.PublicRepository', - ) - custom_repository: 'RemoteRepositoryConfig.MavenRepository.CustomRepository' = proto.Field( - proto.MESSAGE, - number=3, - oneof='upstream', - message='RemoteRepositoryConfig.MavenRepository.CustomRepository', - ) - - class NpmRepository(proto.Message): - r"""Configuration for a Npm remote repository. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - public_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.NpmRepository.PublicRepository): - One of the publicly available Npm - repositories supported by Artifact Registry. - - This field is a member of `oneof`_ ``upstream``. - custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.NpmRepository.CustomRepository): - Customer-specified remote repository. - - This field is a member of `oneof`_ ``upstream``. - """ - class PublicRepository(proto.Enum): - r"""Predefined list of publicly available NPM repositories like - npmjs. - - Values: - PUBLIC_REPOSITORY_UNSPECIFIED (0): - Unspecified repository. - NPMJS (1): - npmjs. - """ - PUBLIC_REPOSITORY_UNSPECIFIED = 0 - NPMJS = 1 - - class CustomRepository(proto.Message): - r"""Customer-specified publicly available remote repository. - - Attributes: - uri (str): - An http/https uri reference to the upstream - remote repository, for ex: - "https://my.npm.registry/". - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - public_repository: 'RemoteRepositoryConfig.NpmRepository.PublicRepository' = proto.Field( - proto.ENUM, - number=1, - oneof='upstream', - enum='RemoteRepositoryConfig.NpmRepository.PublicRepository', - ) - custom_repository: 'RemoteRepositoryConfig.NpmRepository.CustomRepository' = proto.Field( - proto.MESSAGE, - number=3, - oneof='upstream', - message='RemoteRepositoryConfig.NpmRepository.CustomRepository', - ) - - class PythonRepository(proto.Message): - r"""Configuration for a Python remote repository. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - public_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.PythonRepository.PublicRepository): - One of the publicly available Python - repositories supported by Artifact Registry. - - This field is a member of `oneof`_ ``upstream``. - custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.PythonRepository.CustomRepository): - Customer-specified remote repository. - - This field is a member of `oneof`_ ``upstream``. - """ - class PublicRepository(proto.Enum): - r"""Predefined list of publicly available Python repositories - like PyPI.org. - - Values: - PUBLIC_REPOSITORY_UNSPECIFIED (0): - Unspecified repository. - PYPI (1): - PyPI. - """ - PUBLIC_REPOSITORY_UNSPECIFIED = 0 - PYPI = 1 - - class CustomRepository(proto.Message): - r"""Customer-specified publicly available remote repository. - - Attributes: - uri (str): - An http/https uri reference to the upstream - remote repository, for ex: - "https://my.python.registry/". - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - public_repository: 'RemoteRepositoryConfig.PythonRepository.PublicRepository' = proto.Field( - proto.ENUM, - number=1, - oneof='upstream', - enum='RemoteRepositoryConfig.PythonRepository.PublicRepository', - ) - custom_repository: 'RemoteRepositoryConfig.PythonRepository.CustomRepository' = proto.Field( - proto.MESSAGE, - number=3, - oneof='upstream', - message='RemoteRepositoryConfig.PythonRepository.CustomRepository', - ) - - class AptRepository(proto.Message): - r"""Configuration for an Apt remote repository. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - public_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.AptRepository.PublicRepository): - One of the publicly available Apt - repositories supported by Artifact Registry. - - This field is a member of `oneof`_ ``upstream``. - custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.AptRepository.CustomRepository): - Customer-specified remote repository. - - This field is a member of `oneof`_ ``upstream``. - """ - - class PublicRepository(proto.Message): - r"""Publicly available Apt repositories constructed from a common - repository base and a custom repository path. - - Attributes: - repository_base (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.AptRepository.PublicRepository.RepositoryBase): - A common public repository base for Apt. - repository_path (str): - A custom field to define a path to a specific - repository from the base. - """ - class RepositoryBase(proto.Enum): - r"""Predefined list of publicly available repository bases for - Apt. - - Values: - REPOSITORY_BASE_UNSPECIFIED (0): - Unspecified repository base. - DEBIAN (1): - Debian. - UBUNTU (2): - Ubuntu LTS/Pro. - DEBIAN_SNAPSHOT (3): - Archived Debian. - """ - REPOSITORY_BASE_UNSPECIFIED = 0 - DEBIAN = 1 - UBUNTU = 2 - DEBIAN_SNAPSHOT = 3 - - repository_base: 'RemoteRepositoryConfig.AptRepository.PublicRepository.RepositoryBase' = proto.Field( - proto.ENUM, - number=1, - enum='RemoteRepositoryConfig.AptRepository.PublicRepository.RepositoryBase', - ) - repository_path: str = proto.Field( - proto.STRING, - number=2, - ) - - class CustomRepository(proto.Message): - r"""Customer-specified publicly available remote repository. - - Attributes: - uri (str): - An http/https uri reference to the upstream - remote repository, for ex: - "https://my.apt.registry/". - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - public_repository: 'RemoteRepositoryConfig.AptRepository.PublicRepository' = proto.Field( - proto.MESSAGE, - number=1, - oneof='upstream', - message='RemoteRepositoryConfig.AptRepository.PublicRepository', - ) - custom_repository: 'RemoteRepositoryConfig.AptRepository.CustomRepository' = proto.Field( - proto.MESSAGE, - number=3, - oneof='upstream', - message='RemoteRepositoryConfig.AptRepository.CustomRepository', - ) - - class YumRepository(proto.Message): - r"""Configuration for a Yum remote repository. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - public_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.YumRepository.PublicRepository): - One of the publicly available Yum - repositories supported by Artifact Registry. - - This field is a member of `oneof`_ ``upstream``. - custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.YumRepository.CustomRepository): - Customer-specified remote repository. - - This field is a member of `oneof`_ ``upstream``. - """ - - class PublicRepository(proto.Message): - r"""Publicly available Yum repositories constructed from a common - repository base and a custom repository path. - - Attributes: - repository_base (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.YumRepository.PublicRepository.RepositoryBase): - A common public repository base for Yum. - repository_path (str): - A custom field to define a path to a specific - repository from the base. - """ - class RepositoryBase(proto.Enum): - r"""Predefined list of publicly available repository bases for - Yum. - - Values: - REPOSITORY_BASE_UNSPECIFIED (0): - Unspecified repository base. - CENTOS (1): - CentOS. - CENTOS_DEBUG (2): - CentOS Debug. - CENTOS_VAULT (3): - CentOS Vault. - CENTOS_STREAM (4): - CentOS Stream. - ROCKY (5): - Rocky. - EPEL (6): - Fedora Extra Packages for Enterprise Linux - (EPEL). - """ - REPOSITORY_BASE_UNSPECIFIED = 0 - CENTOS = 1 - CENTOS_DEBUG = 2 - CENTOS_VAULT = 3 - CENTOS_STREAM = 4 - ROCKY = 5 - EPEL = 6 - - repository_base: 'RemoteRepositoryConfig.YumRepository.PublicRepository.RepositoryBase' = proto.Field( - proto.ENUM, - number=1, - enum='RemoteRepositoryConfig.YumRepository.PublicRepository.RepositoryBase', - ) - repository_path: str = proto.Field( - proto.STRING, - number=2, - ) - - class CustomRepository(proto.Message): - r"""Customer-specified publicly available remote repository. - - Attributes: - uri (str): - An http/https uri reference to the upstream - remote repository, for ex: - "https://my.yum.registry/". - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - public_repository: 'RemoteRepositoryConfig.YumRepository.PublicRepository' = proto.Field( - proto.MESSAGE, - number=1, - oneof='upstream', - message='RemoteRepositoryConfig.YumRepository.PublicRepository', - ) - custom_repository: 'RemoteRepositoryConfig.YumRepository.CustomRepository' = proto.Field( - proto.MESSAGE, - number=3, - oneof='upstream', - message='RemoteRepositoryConfig.YumRepository.CustomRepository', - ) - - class CommonRemoteRepository(proto.Message): - r"""Common remote repository settings type. - - Attributes: - uri (str): - Required. A common public repository base for - remote repository. - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - docker_repository: DockerRepository = proto.Field( - proto.MESSAGE, - number=2, - oneof='remote_source', - message=DockerRepository, - ) - maven_repository: MavenRepository = proto.Field( - proto.MESSAGE, - number=3, - oneof='remote_source', - message=MavenRepository, - ) - npm_repository: NpmRepository = proto.Field( - proto.MESSAGE, - number=4, - oneof='remote_source', - message=NpmRepository, - ) - python_repository: PythonRepository = proto.Field( - proto.MESSAGE, - number=5, - oneof='remote_source', - message=PythonRepository, - ) - apt_repository: AptRepository = proto.Field( - proto.MESSAGE, - number=6, - oneof='remote_source', - message=AptRepository, - ) - yum_repository: YumRepository = proto.Field( - proto.MESSAGE, - number=7, - oneof='remote_source', - message=YumRepository, - ) - common_repository: CommonRemoteRepository = proto.Field( - proto.MESSAGE, - number=14, - oneof='remote_source', - message=CommonRemoteRepository, - ) - description: str = proto.Field( - proto.STRING, - number=1, - ) - upstream_credentials: UpstreamCredentials = proto.Field( - proto.MESSAGE, - number=9, - message=UpstreamCredentials, - ) - disable_upstream_validation: bool = proto.Field( - proto.BOOL, - number=12, - ) - - -class Repository(proto.Message): - r"""A Repository for storing artifacts with a specific format. - - This message has `oneof`_ fields (mutually exclusive fields). - For each oneof, at most one member field can be set at the same time. - Setting any member of the oneof automatically clears all other - members. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - maven_config (google.cloud.artifactregistry_v1.types.Repository.MavenRepositoryConfig): - Maven repository config contains repository - level configuration for the repositories of - maven type. - - This field is a member of `oneof`_ ``format_config``. - docker_config (google.cloud.artifactregistry_v1.types.Repository.DockerRepositoryConfig): - Docker repository config contains repository - level configuration for the repositories of - docker type. - - This field is a member of `oneof`_ ``format_config``. - virtual_repository_config (google.cloud.artifactregistry_v1.types.VirtualRepositoryConfig): - Configuration specific for a Virtual - Repository. - - This field is a member of `oneof`_ ``mode_config``. - remote_repository_config (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig): - Configuration specific for a Remote - Repository. - - This field is a member of `oneof`_ ``mode_config``. - name (str): - The name of the repository, for example: - ``projects/p1/locations/us-central1/repositories/repo1``. - For each location in a project, repository names must be - unique. - format_ (google.cloud.artifactregistry_v1.types.Repository.Format): - Optional. The format of packages that are - stored in the repository. - description (str): - The user-provided description of the - repository. - labels (MutableMapping[str, str]): - Labels with user-defined metadata. - This field may contain up to 64 entries. Label - keys and values may be no longer than 63 - characters. Label keys must begin with a - lowercase letter and may only contain lowercase - letters, numeric characters, underscores, and - dashes. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time when the repository was - created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time when the repository was - last updated. - kms_key_name (str): - The Cloud KMS resource name of the customer managed - encryption key that's used to encrypt the contents of the - Repository. Has the form: - ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``. - This value may not be changed after the Repository has been - created. - mode (google.cloud.artifactregistry_v1.types.Repository.Mode): - Optional. The mode of the repository. - cleanup_policies (MutableMapping[str, google.cloud.artifactregistry_v1.types.CleanupPolicy]): - Optional. Cleanup policies for this - repository. Cleanup policies indicate when - certain package versions can be automatically - deleted. Map keys are policy IDs supplied by - users during policy creation. They must unique - within a repository and be under 128 characters - in length. - size_bytes (int): - Output only. The size, in bytes, of all - artifact storage in this repository. - Repositories that are generally available or in - public preview use this to calculate storage - costs. - satisfies_pzs (bool): - Output only. If set, the repository satisfies - physical zone separation. - cleanup_policy_dry_run (bool): - Optional. If true, the cleanup pipeline is - prevented from deleting versions in this - repository. - vulnerability_scanning_config (google.cloud.artifactregistry_v1.types.Repository.VulnerabilityScanningConfig): - Optional. Config and state for vulnerability - scanning of resources within this Repository. - disallow_unspecified_mode (bool): - Optional. If this is true, an unspecified - repo type will be treated as error rather than - defaulting to standard. - satisfies_pzi (bool): - Output only. If set, the repository satisfies - physical zone isolation. - """ - class Format(proto.Enum): - r"""A package format. - - Values: - FORMAT_UNSPECIFIED (0): - Unspecified package format. - DOCKER (1): - Docker package format. - MAVEN (2): - Maven package format. - NPM (3): - NPM package format. - APT (5): - APT package format. - YUM (6): - YUM package format. - PYTHON (8): - Python package format. - KFP (9): - Kubeflow Pipelines package format. - GO (10): - Go package format. - GENERIC (11): - Generic package format. - """ - FORMAT_UNSPECIFIED = 0 - DOCKER = 1 - MAVEN = 2 - NPM = 3 - APT = 5 - YUM = 6 - PYTHON = 8 - KFP = 9 - GO = 10 - GENERIC = 11 - - class Mode(proto.Enum): - r"""The mode configures the repository to serve artifacts from - different sources. - - Values: - MODE_UNSPECIFIED (0): - Unspecified mode. - STANDARD_REPOSITORY (1): - A standard repository storing artifacts. - VIRTUAL_REPOSITORY (2): - A virtual repository to serve artifacts from - one or more sources. - REMOTE_REPOSITORY (3): - A remote repository to serve artifacts from a - remote source. - """ - MODE_UNSPECIFIED = 0 - STANDARD_REPOSITORY = 1 - VIRTUAL_REPOSITORY = 2 - REMOTE_REPOSITORY = 3 - - class MavenRepositoryConfig(proto.Message): - r"""MavenRepositoryConfig is maven related repository details. - Provides additional configuration details for repositories of - the maven format type. - - Attributes: - allow_snapshot_overwrites (bool): - The repository with this flag will allow - publishing the same snapshot versions. - version_policy (google.cloud.artifactregistry_v1.types.Repository.MavenRepositoryConfig.VersionPolicy): - Version policy defines the versions that the - registry will accept. - """ - class VersionPolicy(proto.Enum): - r"""VersionPolicy is the version policy for the repository. - - Values: - VERSION_POLICY_UNSPECIFIED (0): - VERSION_POLICY_UNSPECIFIED - the version policy is not - defined. When the version policy is not defined, no - validation is performed for the versions. - RELEASE (1): - RELEASE - repository will accept only Release - versions. - SNAPSHOT (2): - SNAPSHOT - repository will accept only - Snapshot versions. - """ - VERSION_POLICY_UNSPECIFIED = 0 - RELEASE = 1 - SNAPSHOT = 2 - - allow_snapshot_overwrites: bool = proto.Field( - proto.BOOL, - number=1, - ) - version_policy: 'Repository.MavenRepositoryConfig.VersionPolicy' = proto.Field( - proto.ENUM, - number=2, - enum='Repository.MavenRepositoryConfig.VersionPolicy', - ) - - class DockerRepositoryConfig(proto.Message): - r"""DockerRepositoryConfig is docker related repository details. - Provides additional configuration details for repositories of - the docker format type. - - Attributes: - immutable_tags (bool): - The repository which enabled this flag - prevents all tags from being modified, moved or - deleted. This does not prevent tags from being - created. - """ - - immutable_tags: bool = proto.Field( - proto.BOOL, - number=1, - ) - - class VulnerabilityScanningConfig(proto.Message): - r"""Config on whether to perform vulnerability scanning for - resources in this repository, as well as output fields - describing current state. - - Attributes: - enablement_config (google.cloud.artifactregistry_v1.types.Repository.VulnerabilityScanningConfig.EnablementConfig): - Optional. Config for whether this repository - has vulnerability scanning disabled. - last_enable_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The last time this repository - config was enabled. - enablement_state (google.cloud.artifactregistry_v1.types.Repository.VulnerabilityScanningConfig.EnablementState): - Output only. State of feature enablement, - combining repository enablement config and API - enablement state. - enablement_state_reason (str): - Output only. Reason for the repository state. - """ - class EnablementConfig(proto.Enum): - r"""Config for vulnerability scanning of resources in this - repository. - - Values: - ENABLEMENT_CONFIG_UNSPECIFIED (0): - Not set. This will be treated as INHERITED. - INHERITED (1): - Scanning is Enabled, but dependent on API - enablement. - DISABLED (2): - No automatic vulnerability scanning will be - performed for this repository. - """ - ENABLEMENT_CONFIG_UNSPECIFIED = 0 - INHERITED = 1 - DISABLED = 2 - - class EnablementState(proto.Enum): - r"""Describes the state of vulnerability scanning in this - repository, including both repository enablement and API - enablement. - - Values: - ENABLEMENT_STATE_UNSPECIFIED (0): - Enablement state is unclear. - SCANNING_UNSUPPORTED (1): - Repository does not support vulnerability - scanning. - SCANNING_DISABLED (2): - Vulnerability scanning is disabled for this - repository. - SCANNING_ACTIVE (3): - Vulnerability scanning is active for this - repository. - """ - ENABLEMENT_STATE_UNSPECIFIED = 0 - SCANNING_UNSUPPORTED = 1 - SCANNING_DISABLED = 2 - SCANNING_ACTIVE = 3 - - enablement_config: 'Repository.VulnerabilityScanningConfig.EnablementConfig' = proto.Field( - proto.ENUM, - number=1, - enum='Repository.VulnerabilityScanningConfig.EnablementConfig', - ) - last_enable_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - enablement_state: 'Repository.VulnerabilityScanningConfig.EnablementState' = proto.Field( - proto.ENUM, - number=3, - enum='Repository.VulnerabilityScanningConfig.EnablementState', - ) - enablement_state_reason: str = proto.Field( - proto.STRING, - number=4, - ) - - maven_config: MavenRepositoryConfig = proto.Field( - proto.MESSAGE, - number=9, - oneof='format_config', - message=MavenRepositoryConfig, - ) - docker_config: DockerRepositoryConfig = proto.Field( - proto.MESSAGE, - number=17, - oneof='format_config', - message=DockerRepositoryConfig, - ) - virtual_repository_config: 'VirtualRepositoryConfig' = proto.Field( - proto.MESSAGE, - number=14, - oneof='mode_config', - message='VirtualRepositoryConfig', - ) - remote_repository_config: 'RemoteRepositoryConfig' = proto.Field( - proto.MESSAGE, - number=15, - oneof='mode_config', - message='RemoteRepositoryConfig', - ) - name: str = proto.Field( - proto.STRING, - number=1, - ) - format_: Format = proto.Field( - proto.ENUM, - number=2, - enum=Format, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - kms_key_name: str = proto.Field( - proto.STRING, - number=8, - ) - mode: Mode = proto.Field( - proto.ENUM, - number=10, - enum=Mode, - ) - cleanup_policies: MutableMapping[str, 'CleanupPolicy'] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=12, - message='CleanupPolicy', - ) - size_bytes: int = proto.Field( - proto.INT64, - number=13, - ) - satisfies_pzs: bool = proto.Field( - proto.BOOL, - number=16, - ) - cleanup_policy_dry_run: bool = proto.Field( - proto.BOOL, - number=18, - ) - vulnerability_scanning_config: VulnerabilityScanningConfig = proto.Field( - proto.MESSAGE, - number=19, - message=VulnerabilityScanningConfig, - ) - disallow_unspecified_mode: bool = proto.Field( - proto.BOOL, - number=21, - ) - satisfies_pzi: bool = proto.Field( - proto.BOOL, - number=22, - ) - - -class ListRepositoriesRequest(proto.Message): - r"""The request to list repositories. - - Attributes: - parent (str): - Required. The name of the parent resource - whose repositories will be listed. - page_size (int): - The maximum number of repositories to return. - Maximum page size is 1,000. - page_token (str): - The next_page_token value returned from a previous list - request, if any. - filter (str): - Optional. An expression for filtering the results of the - request. Filter rules are case insensitive. The fields - eligible for filtering are: - - - ``name`` - - Examples of using a filter: - - To filter the results of your request to repositories with - the name ``my-repo`` in project ``my-project`` in the - ``us-central`` region, append the following filter - expression to your request: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo"`` - - You can also use wildcards to match any number of characters - before or after the value: - - - ``name="projects/my-project/locations/us-central1/repositories/my-*"`` - - ``name="projects/my-project/locations/us-central1/repositories/*repo"`` - - ``name="projects/my-project/locations/us-central1/repositories/*repo*"`` - order_by (str): - Optional. The field to order the results by. - """ - - 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, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListRepositoriesResponse(proto.Message): - r"""The response from listing repositories. - - Attributes: - repositories (MutableSequence[google.cloud.artifactregistry_v1.types.Repository]): - The repositories returned. - next_page_token (str): - The token to retrieve the next page of - repositories, or empty if there are no more - repositories to return. - """ - - @property - def raw_page(self): - return self - - repositories: MutableSequence['Repository'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Repository', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetRepositoryRequest(proto.Message): - r"""The request to retrieve a repository. - - Attributes: - name (str): - Required. The name of the repository to - retrieve. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateRepositoryRequest(proto.Message): - r"""The request to create a new repository. - - Attributes: - parent (str): - Required. The name of the parent resource - where the repository will be created. - repository_id (str): - Required. The repository id to use for this - repository. - repository (google.cloud.artifactregistry_v1.types.Repository): - Required. The repository to be created. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - repository_id: str = proto.Field( - proto.STRING, - number=2, - ) - repository: 'Repository' = proto.Field( - proto.MESSAGE, - number=3, - message='Repository', - ) - - -class UpdateRepositoryRequest(proto.Message): - r"""The request to update a repository. - - Attributes: - repository (google.cloud.artifactregistry_v1.types.Repository): - The repository that replaces the resource on - the server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - repository: 'Repository' = proto.Field( - proto.MESSAGE, - number=1, - message='Repository', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteRepositoryRequest(proto.Message): - r"""The request to delete a repository. - - Attributes: - name (str): - Required. The name of the repository to - delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/service.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/service.py deleted file mode 100644 index c172cc600d89..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/service.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'OperationMetadata', - }, -) - - -class OperationMetadata(proto.Message): - r"""Metadata type for longrunning-operations, currently empty. - """ - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/settings.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/settings.py deleted file mode 100644 index 0ec626a35fa4..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/settings.py +++ /dev/null @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'ProjectSettings', - 'GetProjectSettingsRequest', - 'UpdateProjectSettingsRequest', - }, -) - - -class ProjectSettings(proto.Message): - r"""The Artifact Registry settings that apply to a Project. - - Attributes: - name (str): - The name of the project's settings. - - Always of the form: - - projects/{project-id}/projectSettings - - In update request: never set - In response: always set - legacy_redirection_state (google.cloud.artifactregistry_v1.types.ProjectSettings.RedirectionState): - The redirection state of the legacy - repositories in this project. - pull_percent (int): - The percentage of pull traffic to redirect - from GCR to AR when using partial redirection. - """ - class RedirectionState(proto.Enum): - r"""The possible redirection states for legacy repositories. - - Values: - REDIRECTION_STATE_UNSPECIFIED (0): - No redirection status has been set. - REDIRECTION_FROM_GCR_IO_DISABLED (1): - Redirection is disabled. - REDIRECTION_FROM_GCR_IO_ENABLED (2): - Redirection is enabled. - REDIRECTION_FROM_GCR_IO_FINALIZED (3): - Redirection is enabled, and has been - finalized so cannot be reverted. - REDIRECTION_FROM_GCR_IO_ENABLED_AND_COPYING (5): - Redirection is enabled and missing images are - copied from GCR - REDIRECTION_FROM_GCR_IO_PARTIAL_AND_COPYING (6): - Redirection is partially enabled and missing - images are copied from GCR - """ - REDIRECTION_STATE_UNSPECIFIED = 0 - REDIRECTION_FROM_GCR_IO_DISABLED = 1 - REDIRECTION_FROM_GCR_IO_ENABLED = 2 - REDIRECTION_FROM_GCR_IO_FINALIZED = 3 - REDIRECTION_FROM_GCR_IO_ENABLED_AND_COPYING = 5 - REDIRECTION_FROM_GCR_IO_PARTIAL_AND_COPYING = 6 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - legacy_redirection_state: RedirectionState = proto.Field( - proto.ENUM, - number=2, - enum=RedirectionState, - ) - pull_percent: int = proto.Field( - proto.INT32, - number=3, - ) - - -class GetProjectSettingsRequest(proto.Message): - r"""Gets the redirection status for a project. - - Attributes: - name (str): - Required. The name of the projectSettings - resource. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateProjectSettingsRequest(proto.Message): - r"""Sets the settings of the project. - - Attributes: - project_settings (google.cloud.artifactregistry_v1.types.ProjectSettings): - The project settings. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Field mask to support partial updates. - """ - - project_settings: 'ProjectSettings' = proto.Field( - proto.MESSAGE, - number=2, - message='ProjectSettings', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/tag.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/tag.py deleted file mode 100644 index 7d85587485ff..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/tag.py +++ /dev/null @@ -1,238 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'Tag', - 'ListTagsRequest', - 'ListTagsResponse', - 'GetTagRequest', - 'CreateTagRequest', - 'UpdateTagRequest', - 'DeleteTagRequest', - }, -) - - -class Tag(proto.Message): - r"""Tags point to a version and represent an alternative name - that can be used to access the version. - - Attributes: - name (str): - The name of the tag, for example: - "projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/tags/tag1". - If the package part contains slashes, the slashes are - escaped. The tag part can only have characters in - [a-zA-Z0-9-._~:@], anything else must be URL encoded. - version (str): - The name of the version the tag refers to, for example: - ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/sha256:5243811`` - If the package or version ID parts contain slashes, the - slashes are escaped. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - version: str = proto.Field( - proto.STRING, - number=2, - ) - - -class ListTagsRequest(proto.Message): - r"""The request to list tags. - - Attributes: - parent (str): - The name of the parent package whose tags will be listed. - For example: - ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1``. - filter (str): - An expression for filtering the results of the request. - Filter rules are case insensitive. The fields eligible for - filtering are: - - - ``name`` - - ``version`` - - Examples of using a filter: - - To filter the results of your request to tags with the name - ``my-tag`` in package ``my-package`` in repository - ``my-repo`` in project "``y-project`` in the us-central - region, append the following filter expression to your - request: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/tags/my-tag"`` - - You can also use wildcards to match any number of characters - before or after the value: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/tags/my*"`` - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/tags/*tag"`` - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/tags/*tag*"`` - - To filter the results of your request to tags applied to the - version ``1.0`` in package ``my-package``, append the - following filter expression to your request: - - - ``version="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/1.0"`` - page_size (int): - The maximum number of tags to return. Maximum - page size is 1,000. - page_token (str): - The next_page_token value returned from a previous list - request, if any. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - - -class ListTagsResponse(proto.Message): - r"""The response from listing tags. - - Attributes: - tags (MutableSequence[google.cloud.artifactregistry_v1.types.Tag]): - The tags returned. - next_page_token (str): - The token to retrieve the next page of tags, - or empty if there are no more tags to return. - """ - - @property - def raw_page(self): - return self - - tags: MutableSequence['Tag'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Tag', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetTagRequest(proto.Message): - r"""The request to retrieve a tag. - - Attributes: - name (str): - The name of the tag to retrieve. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateTagRequest(proto.Message): - r"""The request to create a new tag. - - Attributes: - parent (str): - The name of the parent resource where the tag - will be created. - tag_id (str): - The tag id to use for this repository. - tag (google.cloud.artifactregistry_v1.types.Tag): - The tag to be created. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - tag_id: str = proto.Field( - proto.STRING, - number=2, - ) - tag: 'Tag' = proto.Field( - proto.MESSAGE, - number=3, - message='Tag', - ) - - -class UpdateTagRequest(proto.Message): - r"""The request to create or update a tag. - - Attributes: - tag (google.cloud.artifactregistry_v1.types.Tag): - The tag that replaces the resource on the - server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - tag: 'Tag' = proto.Field( - proto.MESSAGE, - number=1, - message='Tag', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteTagRequest(proto.Message): - r"""The request to delete a tag. - - Attributes: - name (str): - The name of the tag to delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/version.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/version.py deleted file mode 100644 index 79646ff8581f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/version.py +++ /dev/null @@ -1,368 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.cloud.artifactregistry_v1.types import tag -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'VersionView', - 'Version', - 'ListVersionsRequest', - 'ListVersionsResponse', - 'GetVersionRequest', - 'DeleteVersionRequest', - 'BatchDeleteVersionsRequest', - 'BatchDeleteVersionsMetadata', - 'UpdateVersionRequest', - }, -) - - -class VersionView(proto.Enum): - r"""The view, which determines what version information is - returned in a response. - - Values: - VERSION_VIEW_UNSPECIFIED (0): - The default / unset value. - The API will default to the BASIC view. - BASIC (1): - Includes basic information about the version, - but not any related tags. - FULL (2): - Include everything. - """ - VERSION_VIEW_UNSPECIFIED = 0 - BASIC = 1 - FULL = 2 - - -class Version(proto.Message): - r"""The body of a version resource. A version resource represents - a collection of components, such as files and other data. This - may correspond to a version in many package management schemes. - - Attributes: - name (str): - The name of the version, for example: - ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/art1``. - If the package or version ID parts contain slashes, the - slashes are escaped. - description (str): - Optional. Description of the version, as - specified in its metadata. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the version was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the version was last updated. - related_tags (MutableSequence[google.cloud.artifactregistry_v1.types.Tag]): - Output only. A list of related tags. Will - contain up to 100 tags that reference this - version. - 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 - resources could be: - [DockerImage][google.devtools.artifactregistry.v1.DockerImage] - [MavenArtifact][google.devtools.artifactregistry.v1.MavenArtifact] - annotations (MutableMapping[str, str]): - Optional. Client specified annotations. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - related_tags: MutableSequence[tag.Tag] = proto.RepeatedField( - proto.MESSAGE, - number=7, - message=tag.Tag, - ) - metadata: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=8, - message=struct_pb2.Struct, - ) - annotations: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=9, - ) - - -class ListVersionsRequest(proto.Message): - r"""The request to list versions. - - Attributes: - parent (str): - The name of the parent resource whose - versions will be listed. - page_size (int): - The maximum number of versions to return. - Maximum page size is 1,000. - page_token (str): - The next_page_token value returned from a previous list - request, if any. - view (google.cloud.artifactregistry_v1.types.VersionView): - The view that should be returned in the - response. - order_by (str): - Optional. The field to order the results by. - filter (str): - Optional. An expression for filtering the results of the - request. Filter rules are case insensitive. The fields - eligible for filtering are: - - - ``name`` - - ``annotations`` - - Examples of using a filter: - - To filter the results of your request to versions with the - name ``my-version`` in project ``my-project`` in the - ``us-central`` region, in repository ``my-repo``, append the - following filter expression to your request: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/my-version"`` - - You can also use wildcards to match any number of characters - before or after the value: - - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/*version"`` - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/my*"`` - - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/*version*"`` - - To filter the results of your request to versions with the - annotation key-value pair [``external_link``: - ``external_link_value``], append the following filter - expression to your request: - - - ``"annotations.external_link:external_link_value"`` - - To filter just for a specific annotation key - ``external_link``, append the following filter expression to - your request: - - - ``"annotations.external_link"`` - - If the annotation key or value contains special characters, - you can escape them by surrounding the value with backticks. - For example, to filter the results of your request to - versions with the annotation key-value pair - [``external.link``:``https://example.com/my-version``], - append the following filter expression to your request: - - - :literal:`"annotations.`external.link`:`https://example.com/my-version`"` - - You can also filter with annotations with a wildcard to - match any number of characters before or after the value: - - - :literal:`"annotations.*_link:`*example.com*`"` - """ - - 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, - ) - view: 'VersionView' = proto.Field( - proto.ENUM, - number=4, - enum='VersionView', - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - filter: str = proto.Field( - proto.STRING, - number=6, - ) - - -class ListVersionsResponse(proto.Message): - r"""The response from listing versions. - - Attributes: - versions (MutableSequence[google.cloud.artifactregistry_v1.types.Version]): - The versions returned. - next_page_token (str): - The token to retrieve the next page of - versions, or empty if there are no more versions - to return. - """ - - @property - def raw_page(self): - return self - - versions: MutableSequence['Version'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Version', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetVersionRequest(proto.Message): - r"""The request to retrieve a version. - - Attributes: - name (str): - The name of the version to retrieve. - view (google.cloud.artifactregistry_v1.types.VersionView): - The view that should be returned in the - response. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - view: 'VersionView' = proto.Field( - proto.ENUM, - number=2, - enum='VersionView', - ) - - -class DeleteVersionRequest(proto.Message): - r"""The request to delete a version. - - Attributes: - name (str): - The name of the version to delete. - force (bool): - By default, a version that is tagged may not - be deleted. If force=true, the version and any - tags pointing to the version are deleted. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - force: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class BatchDeleteVersionsRequest(proto.Message): - r"""The request to delete multiple versions across a repository. - - Attributes: - parent (str): - The name of the repository holding all - requested versions. - names (MutableSequence[str]): - Required. The names of the versions to - delete. A maximum of 10000 versions can be - deleted in a batch. - validate_only (bool): - If true, the request is performed without - deleting data, following AIP-163. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - names: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=2, - ) - validate_only: bool = proto.Field( - proto.BOOL, - number=3, - ) - - -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, - ) - - -class UpdateVersionRequest(proto.Message): - r"""The request to update a version. - - Attributes: - version (google.cloud.artifactregistry_v1.types.Version): - Required. The Version that replaces the - resource on the server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - version: 'Version' = proto.Field( - proto.MESSAGE, - number=1, - message='Version', - ) - 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/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/vpcsc_config.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/vpcsc_config.py deleted file mode 100644 index 82d41d6fb050..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/vpcsc_config.py +++ /dev/null @@ -1,122 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # 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/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/yum_artifact.py b/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/yum_artifact.py deleted file mode 100644 index e759343f1bf7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/yum_artifact.py +++ /dev/null @@ -1,194 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.rpc import status_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', - manifest={ - 'YumArtifact', - 'ImportYumArtifactsGcsSource', - 'ImportYumArtifactsRequest', - 'ImportYumArtifactsErrorInfo', - 'ImportYumArtifactsResponse', - 'ImportYumArtifactsMetadata', - }, -) - - -class YumArtifact(proto.Message): - r"""A detailed representation of a Yum artifact. - - Attributes: - name (str): - Output only. The Artifact Registry resource - name of the artifact. - package_name (str): - Output only. The yum package name of the - artifact. - package_type (google.cloud.artifactregistry_v1.types.YumArtifact.PackageType): - Output only. An artifact is a binary or - source package. - architecture (str): - Output only. Operating system architecture of - the artifact. - """ - class PackageType(proto.Enum): - r"""Package type is either binary or source. - - Values: - PACKAGE_TYPE_UNSPECIFIED (0): - Package type is not specified. - BINARY (1): - Binary package (.rpm). - SOURCE (2): - Source package (.srpm). - """ - PACKAGE_TYPE_UNSPECIFIED = 0 - BINARY = 1 - SOURCE = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - package_name: str = proto.Field( - proto.STRING, - number=2, - ) - package_type: PackageType = proto.Field( - proto.ENUM, - number=3, - enum=PackageType, - ) - architecture: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ImportYumArtifactsGcsSource(proto.Message): - r"""Google Cloud Storage location where the artifacts currently - reside. - - Attributes: - uris (MutableSequence[str]): - Cloud Storage paths URI (e.g., gs://my_bucket//my_object). - use_wildcards (bool): - Supports URI wildcards for matching multiple - objects from a single URI. - """ - - uris: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - use_wildcards: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class ImportYumArtifactsRequest(proto.Message): - r"""The request to import new yum artifacts. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.artifactregistry_v1.types.ImportYumArtifactsGcsSource): - Google Cloud Storage location where input - content is located. - - This field is a member of `oneof`_ ``source``. - parent (str): - The name of the parent resource where the - artifacts will be imported. - """ - - gcs_source: 'ImportYumArtifactsGcsSource' = proto.Field( - proto.MESSAGE, - number=2, - oneof='source', - message='ImportYumArtifactsGcsSource', - ) - parent: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ImportYumArtifactsErrorInfo(proto.Message): - r"""Error information explaining why a package was not imported. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.artifactregistry_v1.types.ImportYumArtifactsGcsSource): - Google Cloud Storage location requested. - - This field is a member of `oneof`_ ``source``. - error (google.rpc.status_pb2.Status): - The detailed error status. - """ - - gcs_source: 'ImportYumArtifactsGcsSource' = proto.Field( - proto.MESSAGE, - number=1, - oneof='source', - message='ImportYumArtifactsGcsSource', - ) - error: status_pb2.Status = proto.Field( - proto.MESSAGE, - number=2, - message=status_pb2.Status, - ) - - -class ImportYumArtifactsResponse(proto.Message): - r"""The response message from importing YUM artifacts. - - Attributes: - yum_artifacts (MutableSequence[google.cloud.artifactregistry_v1.types.YumArtifact]): - The yum artifacts imported. - errors (MutableSequence[google.cloud.artifactregistry_v1.types.ImportYumArtifactsErrorInfo]): - Detailed error info for packages that were - not imported. - """ - - yum_artifacts: MutableSequence['YumArtifact'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='YumArtifact', - ) - errors: MutableSequence['ImportYumArtifactsErrorInfo'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='ImportYumArtifactsErrorInfo', - ) - - -class ImportYumArtifactsMetadata(proto.Message): - r"""The operation metadata for importing artifacts. - """ - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/mypy.ini b/owl-bot-staging/google-cloud-artifact-registry/v1/mypy.ini deleted file mode 100644 index 574c5aed394b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.7 -namespace_packages = True diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/noxfile.py b/owl-bot-staging/google-cloud-artifact-registry/v1/noxfile.py deleted file mode 100644 index c8d3139b7b27..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/noxfile.py +++ /dev/null @@ -1,280 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import os -import pathlib -import re -import shutil -import subprocess -import sys - - -import nox # type: ignore - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", - "3.13", -] - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = 'google-cloud-artifact-registry' - -BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] -DEFAULT_PYTHON_VERSION = "3.13" - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", - "blacken", - "lint", - "prerelease_deps", -] - -@nox.session(python=ALL_PYTHON) -@nox.parametrize( - "protobuf_implementation", - [ "python", "upb", "cpp" ], -) -def unit(session, protobuf_implementation): - """Run the unit test suite.""" - - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): - session.skip("cpp implementation is not supported in python 3.11+") - - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - session.install('-e', '.', "-c", f"testing/constraints-{session.python}.txt") - - # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. - # The 'cpp' implementation requires Protobuf<4. - if protobuf_implementation == "cpp": - session.install("protobuf<4") - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/artifactregistry_v1/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)), - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) - -@nox.session(python=ALL_PYTHON[-1]) -@nox.parametrize( - "protobuf_implementation", - [ "python", "upb", "cpp" ], -) -def prerelease_deps(session, protobuf_implementation): - """Run the unit test suite against pre-release versions of dependencies.""" - - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): - session.skip("cpp implementation is not supported in python 3.11+") - - # Install test environment dependencies - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - - # Install the package without dependencies - session.install('-e', '.', '--no-deps') - - # We test the minimum dependency versions using the minimum Python - # version so the lowest python runtime that we test has a corresponding constraints - # file, located at `testing/constraints--.txt`, which contains all of the - # dependencies and extras. - with open( - CURRENT_DIRECTORY - / "testing" - / f"constraints-{ALL_PYTHON[0]}.txt", - encoding="utf-8", - ) as constraints_file: - constraints_text = constraints_file.read() - - # Ignore leading whitespace and comment lines. - constraints_deps = [ - match.group(1) - for match in re.finditer( - r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE - ) - ] - - session.install(*constraints_deps) - - prerel_deps = [ - "googleapis-common-protos", - "google-api-core", - "google-auth", - # Exclude grpcio!=1.67.0rc1 which does not support python 3.13 - "grpcio!=1.67.0rc1", - "grpcio-status", - "protobuf", - "proto-plus", - ] - - for dep in prerel_deps: - session.install("--pre", "--no-deps", "--upgrade", dep) - - # Remaining dependencies - other_deps = [ - "requests", - ] - session.install(*other_deps) - - # Print out prerelease package versions - - session.run("python", "-c", "import google.api_core; print(google.api_core.__version__)") - session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("python", "-c", "import grpc; print(grpc.__version__)") - session.run( - "python", "-c", "import google.protobuf; print(google.protobuf.__version__)" - ) - session.run( - "python", "-c", "import proto; print(proto.__version__)" - ) - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/artifactregistry_v1/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)), - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=ALL_PYTHON) -def mypy(session): - """Run the type checker.""" - session.install( - 'mypy', - 'types-requests', - 'types-protobuf' - ) - session.install('.') - session.run( - 'mypy', - '-p', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx==7.0.1", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): - """Run linters. - - Returns a failure if the linters find linting errors or sufficiently - serious code quality issues. - """ - session.install("flake8", BLACK_VERSION) - session.run( - "black", - "--check", - *BLACK_PATHS, - ) - session.run("flake8", "google", "tests", "samples") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *BLACK_PATHS, - ) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_batch_delete_versions_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_batch_delete_versions_async.py deleted file mode 100644 index 61fcc4fde3b0..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_batch_delete_versions_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 BatchDeleteVersions -# 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_BatchDeleteVersions_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_batch_delete_versions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.BatchDeleteVersionsRequest( - names=['names_value1', 'names_value2'], - ) - - # Make the request - operation = client.batch_delete_versions(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_BatchDeleteVersions_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_batch_delete_versions_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_batch_delete_versions_sync.py deleted file mode 100644 index b4145448c8a8..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_batch_delete_versions_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 BatchDeleteVersions -# 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_BatchDeleteVersions_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_batch_delete_versions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.BatchDeleteVersionsRequest( - names=['names_value1', 'names_value2'], - ) - - # Make the request - operation = client.batch_delete_versions(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_BatchDeleteVersions_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_repository_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_repository_async.py deleted file mode 100644 index 7b607f463d4f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_repository_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 CreateRepository -# 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_CreateRepository_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_create_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateRepositoryRequest( - parent="parent_value", - repository_id="repository_id_value", - ) - - # Make the request - operation = client.create_repository(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_CreateRepository_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_repository_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_repository_sync.py deleted file mode 100644 index abf449ef9893..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_repository_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 CreateRepository -# 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_CreateRepository_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_create_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateRepositoryRequest( - parent="parent_value", - repository_id="repository_id_value", - ) - - # Make the request - operation = client.create_repository(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_CreateRepository_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_tag_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_tag_async.py deleted file mode 100644 index b615ff5d2b7b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_tag_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 CreateTag -# 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_CreateTag_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_create_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateTagRequest( - ) - - # Make the request - response = await client.create_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_CreateTag_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_tag_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_tag_sync.py deleted file mode 100644 index a8d64956376f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_tag_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 CreateTag -# 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_CreateTag_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_create_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.CreateTagRequest( - ) - - # Make the request - response = client.create_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_CreateTag_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_package_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_package_async.py deleted file mode 100644 index 45395dc74747..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_package_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeletePackage -# 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_DeletePackage_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_delete_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeletePackageRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_package(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_DeletePackage_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_package_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_package_sync.py deleted file mode 100644 index dc76a9a7fc79..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_package_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeletePackage -# 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_DeletePackage_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_delete_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeletePackageRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_package(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_DeletePackage_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_repository_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_repository_async.py deleted file mode 100644 index 55549b89d886..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_repository_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteRepository -# 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_DeleteRepository_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_delete_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteRepositoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_repository(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_DeleteRepository_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py deleted file mode 100644 index 0b4808655563..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteRepository -# 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_DeleteRepository_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_delete_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteRepositoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_repository(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_DeleteRepository_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_tag_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_tag_async.py deleted file mode 100644 index 9d3779701d9d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_tag_async.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteTag -# 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_DeleteTag_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_delete_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteTagRequest( - ) - - # Make the request - await client.delete_tag(request=request) - - -# [END artifactregistry_v1_generated_ArtifactRegistry_DeleteTag_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py deleted file mode 100644 index c3c6d3b6f58f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteTag -# 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_DeleteTag_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_delete_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteTagRequest( - ) - - # Make the request - client.delete_tag(request=request) - - -# [END artifactregistry_v1_generated_ArtifactRegistry_DeleteTag_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_version_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_version_async.py deleted file mode 100644 index 74b91bcb5409..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_version_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteVersion -# 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_DeleteVersion_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_delete_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteVersionRequest( - ) - - # Make the request - operation = client.delete_version(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_DeleteVersion_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_version_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_version_sync.py deleted file mode 100644 index 87b1bdc3eba8..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_version_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteVersion -# 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_DeleteVersion_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_delete_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.DeleteVersionRequest( - ) - - # Make the request - operation = client.delete_version(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_DeleteVersion_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py deleted file mode 100644 index 2a4daa1bed3a..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetDockerImage -# 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_GetDockerImage_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_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) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetDockerImage_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py deleted file mode 100644 index f797bd08a6b9..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetDockerImage -# 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_GetDockerImage_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_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) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetDockerImage_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_async.py deleted file mode 100644 index a028ca3cadc7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetFile -# 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_GetFile_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_file(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetFileRequest( - name="name_value", - ) - - # Make the request - response = await client.get_file(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetFile_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_sync.py deleted file mode 100644 index 8679e00ac365..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_file_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetFile -# 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_GetFile_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_file(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetFileRequest( - name="name_value", - ) - - # Make the request - response = client.get_file(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetFile_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py deleted file mode 100644 index aedafa986b32..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetIamPolicy -# 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_GetIamPolicy_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 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -async def sample_get_iam_policy(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = await client.get_iam_policy(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetIamPolicy_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py deleted file mode 100644 index fe5d70c08c2a..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetIamPolicy -# 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_GetIamPolicy_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 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -def sample_get_iam_policy(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = client.get_iam_policy(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetIamPolicy_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py deleted file mode 100644 index 6d8b86931b4b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py deleted file mode 100644 index 85f8799b2107..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py deleted file mode 100644 index 05daf4794a0c..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py deleted file mode 100644 index 6e7e7dcf2130..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_package_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_package_async.py deleted file mode 100644 index cef87c085308..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_package_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetPackage -# 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_GetPackage_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_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetPackageRequest( - name="name_value", - ) - - # Make the request - response = await client.get_package(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetPackage_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_package_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_package_sync.py deleted file mode 100644 index 62771637ddc6..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_package_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetPackage -# 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_GetPackage_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_package(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetPackageRequest( - name="name_value", - ) - - # Make the request - response = client.get_package(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetPackage_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py deleted file mode 100644 index 46a959ac26fe..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetProjectSettings -# 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_GetProjectSettings_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_project_settings(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetProjectSettingsRequest( - name="name_value", - ) - - # Make the request - response = await client.get_project_settings(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py deleted file mode 100644 index 7847db759848..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetProjectSettings -# 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_GetProjectSettings_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_project_settings(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetProjectSettingsRequest( - name="name_value", - ) - - # Make the request - response = client.get_project_settings(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_async.py deleted file mode 100644 index 8921010a1173..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py deleted file mode 100644 index 4231df0b42e7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_repository_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_repository_async.py deleted file mode 100644 index aa7dbf73a24a..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_repository_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetRepository -# 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_GetRepository_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_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetRepositoryRequest( - name="name_value", - ) - - # Make the request - response = await client.get_repository(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetRepository_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_repository_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_repository_sync.py deleted file mode 100644 index a9a72dad0670..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_repository_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetRepository -# 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_GetRepository_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_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetRepositoryRequest( - name="name_value", - ) - - # Make the request - response = client.get_repository(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetRepository_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_tag_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_tag_async.py deleted file mode 100644 index 0028571ccfff..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_tag_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetTag -# 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_GetTag_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_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetTagRequest( - ) - - # Make the request - response = await client.get_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetTag_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_tag_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_tag_sync.py deleted file mode 100644 index 5e3dd4b1acff..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_tag_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetTag -# 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_GetTag_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_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetTagRequest( - ) - - # Make the request - response = client.get_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetTag_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_version_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_version_async.py deleted file mode 100644 index 95163fd5a8d3..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_version_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetVersion -# 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_GetVersion_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_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetVersionRequest( - ) - - # Make the request - response = await client.get_version(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetVersion_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_version_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_version_sync.py deleted file mode 100644 index 8e3d002f3f0e..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_version_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetVersion -# 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_GetVersion_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_version(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.GetVersionRequest( - ) - - # Make the request - response = client.get_version(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_GetVersion_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py deleted file mode 100644 index fa55e693640a..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py deleted file mode 100644 index ddcd94d6d8cb..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py deleted file mode 100644 index 2103df88054f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ImportAptArtifacts -# 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_ImportAptArtifacts_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_import_apt_artifacts(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ImportAptArtifactsRequest( - ) - - # Make the request - operation = client.import_apt_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ImportAptArtifacts_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py deleted file mode 100644 index da420548b5e3..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ImportAptArtifacts -# 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_ImportAptArtifacts_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_import_apt_artifacts(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ImportAptArtifactsRequest( - ) - - # Make the request - operation = client.import_apt_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ImportAptArtifacts_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py deleted file mode 100644 index dda1294ce498..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ImportYumArtifacts -# 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_ImportYumArtifacts_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_import_yum_artifacts(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ImportYumArtifactsRequest( - ) - - # Make the request - operation = client.import_yum_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ImportYumArtifacts_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py deleted file mode 100644 index 119835a0fd36..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ImportYumArtifacts -# 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_ImportYumArtifacts_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_import_yum_artifacts(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ImportYumArtifactsRequest( - ) - - # Make the request - operation = client.import_yum_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ImportYumArtifacts_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py deleted file mode 100644 index a147bef7e889..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListDockerImages -# 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_ListDockerImages_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_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) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListDockerImages_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py deleted file mode 100644 index e39f01633d30..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListDockerImages -# 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_ListDockerImages_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_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) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListDockerImages_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_async.py deleted file mode 100644 index 22b289207699..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListFiles -# 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_ListFiles_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_files(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListFilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_files(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListFiles_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_sync.py deleted file mode 100644 index 07deda7e5fb5..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_files_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListFiles -# 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_ListFiles_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_files(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListFilesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_files(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListFiles_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py deleted file mode 100644 index 304b09cb9fce..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py deleted file mode 100644 index 5367a71e77b4..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py deleted file mode 100644 index cc608886b633..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py deleted file mode 100644 index 0dd9b4016a60..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_packages_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_packages_async.py deleted file mode 100644 index 51fd69018a0d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_packages_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListPackages -# 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_ListPackages_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_packages(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListPackagesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_packages(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListPackages_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_packages_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_packages_sync.py deleted file mode 100644 index e424af256e42..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_packages_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListPackages -# 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_ListPackages_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_packages(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListPackagesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_packages(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListPackages_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py deleted file mode 100644 index bb7000fd14dc..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py deleted file mode 100644 index 4645d43d0023..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_repositories_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_repositories_async.py deleted file mode 100644 index 4dc2fa081656..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_repositories_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListRepositories -# 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_ListRepositories_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_repositories(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListRepositoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_repositories(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListRepositories_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_repositories_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_repositories_sync.py deleted file mode 100644 index a154519f717d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_repositories_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListRepositories -# 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_ListRepositories_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_repositories(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListRepositoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_repositories(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListRepositories_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_tags_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_tags_async.py deleted file mode 100644 index 3d29e98e8686..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_tags_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListTags -# 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_ListTags_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_tags(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListTagsRequest( - ) - - # Make the request - page_result = client.list_tags(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListTags_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_tags_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_tags_sync.py deleted file mode 100644 index 4cace33e100f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_tags_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListTags -# 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_ListTags_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_tags(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListTagsRequest( - ) - - # Make the request - page_result = client.list_tags(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListTags_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_versions_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_versions_async.py deleted file mode 100644 index 74ee539e8258..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_versions_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListVersions -# 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_ListVersions_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_versions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListVersionsRequest( - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListVersions_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_versions_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_versions_sync.py deleted file mode 100644 index 02d3bda673f9..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_versions_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListVersions -# 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_ListVersions_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_versions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.ListVersionsRequest( - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_ListVersions_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py deleted file mode 100644 index 54d47b801fb7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 SetIamPolicy -# 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_SetIamPolicy_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 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -async def sample_set_iam_policy(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = await client.set_iam_policy(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_SetIamPolicy_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py deleted file mode 100644 index 577627b3ce64..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 SetIamPolicy -# 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_SetIamPolicy_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 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -def sample_set_iam_policy(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = client.set_iam_policy(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_SetIamPolicy_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py deleted file mode 100644 index ee98b7a67bf2..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 TestIamPermissions -# 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_TestIamPermissions_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 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -async def sample_test_iam_permissions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], - ) - - # Make the request - response = await client.test_iam_permissions(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_TestIamPermissions_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py deleted file mode 100644 index f40a4136aff2..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 TestIamPermissions -# 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_TestIamPermissions_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 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -def sample_test_iam_permissions(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], - ) - - # Make the request - response = client.test_iam_permissions(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_TestIamPermissions_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_project_settings_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_project_settings_async.py deleted file mode 100644 index fe569cad7073..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_project_settings_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateProjectSettings -# 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_UpdateProjectSettings_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_project_settings(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateProjectSettingsRequest( - ) - - # Make the request - response = await client.update_project_settings(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_UpdateProjectSettings_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py deleted file mode 100644 index 194a62d73565..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateProjectSettings -# 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_UpdateProjectSettings_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_project_settings(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateProjectSettingsRequest( - ) - - # Make the request - response = client.update_project_settings(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_UpdateProjectSettings_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_repository_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_repository_async.py deleted file mode 100644 index 125dd06ade2b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_repository_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateRepository -# 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_UpdateRepository_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_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateRepositoryRequest( - ) - - # Make the request - response = await client.update_repository(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_UpdateRepository_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_repository_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_repository_sync.py deleted file mode 100644 index c32576e582fd..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_repository_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateRepository -# 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_UpdateRepository_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_repository(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateRepositoryRequest( - ) - - # Make the request - response = client.update_repository(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_UpdateRepository_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_tag_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_tag_async.py deleted file mode 100644 index 116d004586e1..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_tag_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateTag -# 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_UpdateTag_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_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateTagRequest( - ) - - # Make the request - response = await client.update_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_UpdateTag_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_tag_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_tag_sync.py deleted file mode 100644 index 1485cd9e330a..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_tag_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateTag -# 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_UpdateTag_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_tag(): - # Create a client - client = artifactregistry_v1.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1.UpdateTagRequest( - ) - - # Make the request - response = client.update_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1_generated_ArtifactRegistry_UpdateTag_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py deleted file mode 100644 index 0f815c3a9bf7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py deleted file mode 100644 index 59f210045eff..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json b/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json deleted file mode 100644 index a1f492c7ad92..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json +++ /dev/null @@ -1,7988 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.devtools.artifactregistry.v1", - "version": "v1" - } - ], - "language": "PYTHON", - "name": "google-cloud-artifact-registry", - "version": "0.1.0" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.batch_delete_versions", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.BatchDeleteVersions", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "BatchDeleteVersions" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.BatchDeleteVersionsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "names", - "type": "MutableSequence[str]" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "batch_delete_versions" - }, - "description": "Sample for BatchDeleteVersions", - "file": "artifactregistry_v1_generated_artifact_registry_batch_delete_versions_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_BatchDeleteVersions_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_batch_delete_versions_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.batch_delete_versions", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.BatchDeleteVersions", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "BatchDeleteVersions" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.BatchDeleteVersionsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "names", - "type": "MutableSequence[str]" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "batch_delete_versions" - }, - "description": "Sample for BatchDeleteVersions", - "file": "artifactregistry_v1_generated_artifact_registry_batch_delete_versions_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_BatchDeleteVersions_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_batch_delete_versions_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_attachment", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateAttachment", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateAttachment" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateAttachmentRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "attachment", - "type": "google.cloud.artifactregistry_v1.types.Attachment" - }, - { - "name": "attachment_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_attachment" - }, - "description": "Sample for CreateAttachment", - "file": "artifactregistry_v1_generated_artifact_registry_create_attachment_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateAttachment_async", - "segments": [ - { - "end": 61, - "start": 27, - "type": "FULL" - }, - { - "end": 61, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 58, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 62, - "start": 59, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_create_attachment_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_attachment", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateAttachment", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateAttachment" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateAttachmentRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "attachment", - "type": "google.cloud.artifactregistry_v1.types.Attachment" - }, - { - "name": "attachment_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_attachment" - }, - "description": "Sample for CreateAttachment", - "file": "artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateAttachment_sync", - "segments": [ - { - "end": 61, - "start": 27, - "type": "FULL" - }, - { - "end": 61, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 58, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 62, - "start": 59, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateRepositoryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "repository", - "type": "google.cloud.artifactregistry_v1.types.Repository" - }, - { - "name": "repository_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_repository" - }, - "description": "Sample for CreateRepository", - "file": "artifactregistry_v1_generated_artifact_registry_create_repository_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRepository_async", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_create_repository_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateRepositoryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "repository", - "type": "google.cloud.artifactregistry_v1.types.Repository" - }, - { - "name": "repository_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_repository" - }, - "description": "Sample for CreateRepository", - "file": "artifactregistry_v1_generated_artifact_registry_create_repository_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRepository_sync", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_create_repository_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_rule", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRule", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateRuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "rule", - "type": "google.cloud.artifactregistry_v1.types.Rule" - }, - { - "name": "rule_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.artifactregistry_v1.types.Rule", - "shortName": "create_rule" - }, - "description": "Sample for CreateRule", - "file": "artifactregistry_v1_generated_artifact_registry_create_rule_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRule_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_create_rule_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_rule", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRule", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateRuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "rule", - "type": "google.cloud.artifactregistry_v1.types.Rule" - }, - { - "name": "rule_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.artifactregistry_v1.types.Rule", - "shortName": "create_rule" - }, - "description": "Sample for CreateRule", - "file": "artifactregistry_v1_generated_artifact_registry_create_rule_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRule_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_create_rule_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateTagRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "tag", - "type": "google.cloud.artifactregistry_v1.types.Tag" - }, - { - "name": "tag_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "create_tag" - }, - "description": "Sample for CreateTag", - "file": "artifactregistry_v1_generated_artifact_registry_create_tag_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateTag_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_create_tag_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateTagRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "tag", - "type": "google.cloud.artifactregistry_v1.types.Tag" - }, - { - "name": "tag_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "create_tag" - }, - "description": "Sample for CreateTag", - "file": "artifactregistry_v1_generated_artifact_registry_create_tag_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateTag_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_create_tag_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_attachment", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteAttachment", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteAttachment" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteAttachmentRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_attachment" - }, - "description": "Sample for DeleteAttachment", - "file": "artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteAttachment_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_attachment", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteAttachment", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteAttachment" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteAttachmentRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_attachment" - }, - "description": "Sample for DeleteAttachment", - "file": "artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteAttachment_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_file", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteFile", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteFile" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteFileRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_file" - }, - "description": "Sample for DeleteFile", - "file": "artifactregistry_v1_generated_artifact_registry_delete_file_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteFile_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_file_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_file", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteFile", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteFile" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteFileRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_file" - }, - "description": "Sample for DeleteFile", - "file": "artifactregistry_v1_generated_artifact_registry_delete_file_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteFile_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_file_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeletePackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeletePackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeletePackageRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_package" - }, - "description": "Sample for DeletePackage", - "file": "artifactregistry_v1_generated_artifact_registry_delete_package_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeletePackage_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_package_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeletePackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeletePackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeletePackageRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_package" - }, - "description": "Sample for DeletePackage", - "file": "artifactregistry_v1_generated_artifact_registry_delete_package_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeletePackage_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_package_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteRepositoryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_repository" - }, - "description": "Sample for DeleteRepository", - "file": "artifactregistry_v1_generated_artifact_registry_delete_repository_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRepository_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_repository_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteRepositoryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_repository" - }, - "description": "Sample for DeleteRepository", - "file": "artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRepository_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_rule", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRule", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteRuleRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_rule" - }, - "description": "Sample for DeleteRule", - "file": "artifactregistry_v1_generated_artifact_registry_delete_rule_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRule_async", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_rule_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_rule", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRule", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteRuleRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_rule" - }, - "description": "Sample for DeleteRule", - "file": "artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRule_sync", - "segments": [ - { - "end": 49, - "start": 27, - "type": "FULL" - }, - { - "end": 49, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteTagRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_tag" - }, - "description": "Sample for DeleteTag", - "file": "artifactregistry_v1_generated_artifact_registry_delete_tag_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteTag_async", - "segments": [ - { - "end": 48, - "start": 27, - "type": "FULL" - }, - { - "end": 48, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_tag_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteTagRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_tag" - }, - "description": "Sample for DeleteTag", - "file": "artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteTag_sync", - "segments": [ - { - "end": 48, - "start": 27, - "type": "FULL" - }, - { - "end": 48, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_version", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteVersion", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteVersion" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteVersionRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_version" - }, - "description": "Sample for DeleteVersion", - "file": "artifactregistry_v1_generated_artifact_registry_delete_version_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteVersion_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_delete_version_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_version", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteVersion", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteVersion" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteVersionRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_version" - }, - "description": "Sample for DeleteVersion", - "file": "artifactregistry_v1_generated_artifact_registry_delete_version_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteVersion_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_delete_version_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_attachment", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetAttachment", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetAttachment" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetAttachmentRequest" - }, - { - "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.Attachment", - "shortName": "get_attachment" - }, - "description": "Sample for GetAttachment", - "file": "artifactregistry_v1_generated_artifact_registry_get_attachment_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetAttachment_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_attachment_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_attachment", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetAttachment", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetAttachment" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetAttachmentRequest" - }, - { - "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.Attachment", - "shortName": "get_attachment" - }, - "description": "Sample for GetAttachment", - "file": "artifactregistry_v1_generated_artifact_registry_get_attachment_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetAttachment_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_attachment_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_docker_image", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetDockerImage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetDockerImage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetDockerImageRequest" - }, - { - "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.DockerImage", - "shortName": "get_docker_image" - }, - "description": "Sample for GetDockerImage", - "file": "artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetDockerImage_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_docker_image_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_docker_image", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetDockerImage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetDockerImage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetDockerImageRequest" - }, - { - "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.DockerImage", - "shortName": "get_docker_image" - }, - "description": "Sample for GetDockerImage", - "file": "artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetDockerImage_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_docker_image_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_file", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetFile", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetFile" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetFileRequest" - }, - { - "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.File", - "shortName": "get_file" - }, - "description": "Sample for GetFile", - "file": "artifactregistry_v1_generated_artifact_registry_get_file_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetFile_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_file_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_file", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetFile", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetFile" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetFileRequest" - }, - { - "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.File", - "shortName": "get_file" - }, - "description": "Sample for GetFile", - "file": "artifactregistry_v1_generated_artifact_registry_get_file_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetFile_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_file_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_iam_policy", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetIamPolicy", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetIamPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy" - }, - "description": "Sample for GetIamPolicy", - "file": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetIamPolicy_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_iam_policy", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetIamPolicy", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetIamPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy" - }, - "description": "Sample for GetIamPolicy", - "file": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetIamPolicy_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_maven_artifact", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetMavenArtifact", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetMavenArtifact" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest" - }, - { - "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.MavenArtifact", - "shortName": "get_maven_artifact" - }, - "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_GetMavenArtifact_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_maven_artifact_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_maven_artifact", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetMavenArtifact", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetMavenArtifact" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest" - }, - { - "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.MavenArtifact", - "shortName": "get_maven_artifact" - }, - "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_GetMavenArtifact_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_maven_artifact_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_npm_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetNpmPackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetNpmPackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetNpmPackageRequest" - }, - { - "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.NpmPackage", - "shortName": "get_npm_package" - }, - "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_GetNpmPackage_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_npm_package_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_npm_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetNpmPackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetNpmPackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetNpmPackageRequest" - }, - { - "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.NpmPackage", - "shortName": "get_npm_package" - }, - "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_GetNpmPackage_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_npm_package_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetPackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" - }, - { - "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.Package", - "shortName": "get_package" - }, - "description": "Sample for GetPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_package_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_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_package_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetPackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" - }, - { - "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.Package", - "shortName": "get_package" - }, - "description": "Sample for GetPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_package_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_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_package_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_project_settings", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetProjectSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" - }, - { - "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.ProjectSettings", - "shortName": "get_project_settings" - }, - "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_GetProjectSettings_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_project_settings_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_project_settings", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetProjectSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" - }, - { - "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.ProjectSettings", - "shortName": "get_project_settings" - }, - "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_GetProjectSettings_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_project_settings_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_python_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPythonPackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetPythonPackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPythonPackageRequest" - }, - { - "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.PythonPackage", - "shortName": "get_python_package" - }, - "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_GetPythonPackage_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_python_package_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_python_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPythonPackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetPythonPackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPythonPackageRequest" - }, - { - "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.PythonPackage", - "shortName": "get_python_package" - }, - "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_GetPythonPackage_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_python_package_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" - }, - { - "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.Repository", - "shortName": "get_repository" - }, - "description": "Sample for GetRepository", - "file": "artifactregistry_v1_generated_artifact_registry_get_repository_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_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_repository_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" - }, - { - "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.Repository", - "shortName": "get_repository" - }, - "description": "Sample for GetRepository", - "file": "artifactregistry_v1_generated_artifact_registry_get_repository_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_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_repository_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_rule", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRule", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetRuleRequest" - }, - { - "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.Rule", - "shortName": "get_rule" - }, - "description": "Sample for GetRule", - "file": "artifactregistry_v1_generated_artifact_registry_get_rule_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRule_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_rule_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_rule", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRule", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetRuleRequest" - }, - { - "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.Rule", - "shortName": "get_rule" - }, - "description": "Sample for GetRule", - "file": "artifactregistry_v1_generated_artifact_registry_get_rule_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRule_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_rule_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" - }, - { - "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.Tag", - "shortName": "get_tag" - }, - "description": "Sample for GetTag", - "file": "artifactregistry_v1_generated_artifact_registry_get_tag_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetTag_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_tag_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" - }, - { - "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.Tag", - "shortName": "get_tag" - }, - "description": "Sample for GetTag", - "file": "artifactregistry_v1_generated_artifact_registry_get_tag_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetTag_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_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_attachments", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListAttachments", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListAttachments" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListAttachmentsRequest" - }, - { - "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.ListAttachmentsAsyncPager", - "shortName": "list_attachments" - }, - "description": "Sample for ListAttachments", - "file": "artifactregistry_v1_generated_artifact_registry_list_attachments_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListAttachments_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_attachments_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_attachments", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListAttachments", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListAttachments" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListAttachmentsRequest" - }, - { - "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.ListAttachmentsPager", - "shortName": "list_attachments" - }, - "description": "Sample for ListAttachments", - "file": "artifactregistry_v1_generated_artifact_registry_list_attachments_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListAttachments_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_attachments_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_list_maven_artifacts_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_npm_packages", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListNpmPackages", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListNpmPackages" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest" - }, - { - "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.ListNpmPackagesAsyncPager", - "shortName": "list_npm_packages" - }, - "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_ListNpmPackages_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_npm_packages_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_npm_packages", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListNpmPackages", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListNpmPackages" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest" - }, - { - "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.ListNpmPackagesPager", - "shortName": "list_npm_packages" - }, - "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_ListNpmPackages_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_npm_packages_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_packages", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListPackages" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" - }, - { - "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.ListPackagesAsyncPager", - "shortName": "list_packages" - }, - "description": "Sample for ListPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_packages_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_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_packages_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_packages", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListPackages" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" - }, - { - "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.ListPackagesPager", - "shortName": "list_packages" - }, - "description": "Sample for ListPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_packages_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_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_packages_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_python_packages", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPythonPackages", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListPythonPackages" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest" - }, - { - "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.ListPythonPackagesAsyncPager", - "shortName": "list_python_packages" - }, - "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_ListPythonPackages_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_python_packages_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_python_packages", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPythonPackages", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListPythonPackages" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest" - }, - { - "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.ListPythonPackagesPager", - "shortName": "list_python_packages" - }, - "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_ListPythonPackages_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_python_packages_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_repositories", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRepositories", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListRepositories" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListRepositoriesRequest" - }, - { - "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.ListRepositoriesAsyncPager", - "shortName": "list_repositories" - }, - "description": "Sample for ListRepositories", - "file": "artifactregistry_v1_generated_artifact_registry_list_repositories_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListRepositories_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_repositories_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_repositories", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRepositories", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListRepositories" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListRepositoriesRequest" - }, - { - "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.ListRepositoriesPager", - "shortName": "list_repositories" - }, - "description": "Sample for ListRepositories", - "file": "artifactregistry_v1_generated_artifact_registry_list_repositories_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListRepositories_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_repositories_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_rules", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRules", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListRules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListRulesRequest" - }, - { - "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.ListRulesAsyncPager", - "shortName": "list_rules" - }, - "description": "Sample for ListRules", - "file": "artifactregistry_v1_generated_artifact_registry_list_rules_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListRules_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_rules_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_rules", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRules", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListRules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListRulesRequest" - }, - { - "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.ListRulesPager", - "shortName": "list_rules" - }, - "description": "Sample for ListRules", - "file": "artifactregistry_v1_generated_artifact_registry_list_rules_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListRules_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_rules_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_tags", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListTags", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListTags" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListTagsRequest" - }, - { - "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.ListTagsAsyncPager", - "shortName": "list_tags" - }, - "description": "Sample for ListTags", - "file": "artifactregistry_v1_generated_artifact_registry_list_tags_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListTags_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_list_tags_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_tags", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListTags", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListTags" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListTagsRequest" - }, - { - "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.ListTagsPager", - "shortName": "list_tags" - }, - "description": "Sample for ListTags", - "file": "artifactregistry_v1_generated_artifact_registry_list_tags_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListTags_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_list_tags_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_versions", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListVersions", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListVersions" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListVersionsRequest" - }, - { - "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.ListVersionsAsyncPager", - "shortName": "list_versions" - }, - "description": "Sample for ListVersions", - "file": "artifactregistry_v1_generated_artifact_registry_list_versions_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListVersions_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_list_versions_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_versions", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListVersions", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListVersions" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListVersionsRequest" - }, - { - "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.ListVersionsPager", - "shortName": "list_versions" - }, - "description": "Sample for ListVersions", - "file": "artifactregistry_v1_generated_artifact_registry_list_versions_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListVersions_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_list_versions_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.set_iam_policy", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.SetIamPolicy", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "SetIamPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "set_iam_policy" - }, - "description": "Sample for SetIamPolicy", - "file": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_SetIamPolicy_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.set_iam_policy", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.SetIamPolicy", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "SetIamPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "set_iam_policy" - }, - "description": "Sample for SetIamPolicy", - "file": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_SetIamPolicy_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.test_iam_permissions", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.TestIamPermissions", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "TestIamPermissions" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", - "shortName": "test_iam_permissions" - }, - "description": "Sample for TestIamPermissions", - "file": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_TestIamPermissions_async", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.test_iam_permissions", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.TestIamPermissions", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "TestIamPermissions" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", - "shortName": "test_iam_permissions" - }, - "description": "Sample for TestIamPermissions", - "file": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_TestIamPermissions_sync", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_file", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateFile", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateFile" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateFileRequest" - }, - { - "name": "file", - "type": "google.cloud.artifactregistry_v1.types.File" - }, - { - "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.File", - "shortName": "update_file" - }, - "description": "Sample for UpdateFile", - "file": "artifactregistry_v1_generated_artifact_registry_update_file_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateFile_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_file_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_file", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateFile", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateFile" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateFileRequest" - }, - { - "name": "file", - "type": "google.cloud.artifactregistry_v1.types.File" - }, - { - "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.File", - "shortName": "update_file" - }, - "description": "Sample for UpdateFile", - "file": "artifactregistry_v1_generated_artifact_registry_update_file_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateFile_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_file_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdatePackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdatePackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdatePackageRequest" - }, - { - "name": "package", - "type": "google.cloud.artifactregistry_v1.types.Package" - }, - { - "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.Package", - "shortName": "update_package" - }, - "description": "Sample for UpdatePackage", - "file": "artifactregistry_v1_generated_artifact_registry_update_package_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdatePackage_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_package_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdatePackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdatePackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdatePackageRequest" - }, - { - "name": "package", - "type": "google.cloud.artifactregistry_v1.types.Package" - }, - { - "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.Package", - "shortName": "update_package" - }, - "description": "Sample for UpdatePackage", - "file": "artifactregistry_v1_generated_artifact_registry_update_package_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdatePackage_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_package_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_project_settings", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateProjectSettings", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateProjectSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest" - }, - { - "name": "project_settings", - "type": "google.cloud.artifactregistry_v1.types.ProjectSettings" - }, - { - "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.ProjectSettings", - "shortName": "update_project_settings" - }, - "description": "Sample for UpdateProjectSettings", - "file": "artifactregistry_v1_generated_artifact_registry_update_project_settings_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateProjectSettings_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_project_settings_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_project_settings", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateProjectSettings", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateProjectSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest" - }, - { - "name": "project_settings", - "type": "google.cloud.artifactregistry_v1.types.ProjectSettings" - }, - { - "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.ProjectSettings", - "shortName": "update_project_settings" - }, - "description": "Sample for UpdateProjectSettings", - "file": "artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateProjectSettings_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_project_settings_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateRepositoryRequest" - }, - { - "name": "repository", - "type": "google.cloud.artifactregistry_v1.types.Repository" - }, - { - "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.Repository", - "shortName": "update_repository" - }, - "description": "Sample for UpdateRepository", - "file": "artifactregistry_v1_generated_artifact_registry_update_repository_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRepository_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_repository_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateRepositoryRequest" - }, - { - "name": "repository", - "type": "google.cloud.artifactregistry_v1.types.Repository" - }, - { - "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.Repository", - "shortName": "update_repository" - }, - "description": "Sample for UpdateRepository", - "file": "artifactregistry_v1_generated_artifact_registry_update_repository_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRepository_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_repository_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_rule", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRule", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateRuleRequest" - }, - { - "name": "rule", - "type": "google.cloud.artifactregistry_v1.types.Rule" - }, - { - "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.Rule", - "shortName": "update_rule" - }, - "description": "Sample for UpdateRule", - "file": "artifactregistry_v1_generated_artifact_registry_update_rule_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRule_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_rule_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_rule", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRule", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateRule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateRuleRequest" - }, - { - "name": "rule", - "type": "google.cloud.artifactregistry_v1.types.Rule" - }, - { - "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.Rule", - "shortName": "update_rule" - }, - "description": "Sample for UpdateRule", - "file": "artifactregistry_v1_generated_artifact_registry_update_rule_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRule_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_rule_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateTagRequest" - }, - { - "name": "tag", - "type": "google.cloud.artifactregistry_v1.types.Tag" - }, - { - "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.Tag", - "shortName": "update_tag" - }, - "description": "Sample for UpdateTag", - "file": "artifactregistry_v1_generated_artifact_registry_update_tag_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateTag_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_tag_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateTagRequest" - }, - { - "name": "tag", - "type": "google.cloud.artifactregistry_v1.types.Tag" - }, - { - "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.Tag", - "shortName": "update_tag" - }, - "description": "Sample for UpdateTag", - "file": "artifactregistry_v1_generated_artifact_registry_update_tag_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateTag_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_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" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_version", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVersion", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateVersion" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateVersionRequest" - }, - { - "name": "version", - "type": "google.cloud.artifactregistry_v1.types.Version" - }, - { - "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.Version", - "shortName": "update_version" - }, - "description": "Sample for UpdateVersion", - "file": "artifactregistry_v1_generated_artifact_registry_update_version_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVersion_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_version_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_version", - "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVersion", - "service": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateVersion" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateVersionRequest" - }, - { - "name": "version", - "type": "google.cloud.artifactregistry_v1.types.Version" - }, - { - "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.Version", - "shortName": "update_version" - }, - "description": "Sample for UpdateVersion", - "file": "artifactregistry_v1_generated_artifact_registry_update_version_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVersion_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_version_sync.py" - } - ] -} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/scripts/fixup_artifactregistry_v1_keywords.py b/owl-bot-staging/google-cloud-artifact-registry/v1/scripts/fixup_artifactregistry_v1_keywords.py deleted file mode 100644 index 35798fee7dc3..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/scripts/fixup_artifactregistry_v1_keywords.py +++ /dev/null @@ -1,224 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class artifactregistryCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'batch_delete_versions': ('names', 'parent', 'validate_only', ), - 'create_attachment': ('parent', 'attachment_id', 'attachment', ), - 'create_repository': ('parent', 'repository_id', 'repository', ), - 'create_rule': ('parent', 'rule_id', 'rule', ), - 'create_tag': ('parent', 'tag_id', 'tag', ), - 'delete_attachment': ('name', ), - 'delete_file': ('name', ), - 'delete_package': ('name', ), - 'delete_repository': ('name', ), - 'delete_rule': ('name', ), - 'delete_tag': ('name', ), - 'delete_version': ('name', 'force', ), - 'get_attachment': ('name', ), - '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_rule': ('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_attachments': ('parent', 'filter', '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', 'filter', 'order_by', ), - 'list_python_packages': ('parent', 'page_size', 'page_token', ), - 'list_repositories': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_rules': ('parent', 'page_size', 'page_token', ), - 'list_tags': ('parent', 'filter', 'page_size', 'page_token', ), - 'list_versions': ('parent', 'page_size', 'page_token', 'view', 'order_by', 'filter', ), - 'set_iam_policy': ('resource', 'policy', 'update_mask', ), - 'test_iam_permissions': ('resource', 'permissions', ), - 'update_file': ('file', 'update_mask', ), - 'update_package': ('package', 'update_mask', ), - 'update_project_settings': ('project_settings', 'update_mask', ), - 'update_repository': ('repository', 'update_mask', ), - 'update_rule': ('rule', 'update_mask', ), - 'update_tag': ('tag', 'update_mask', ), - 'update_version': ('version', 'update_mask', ), - 'update_vpcsc_config': ('vpcsc_config', 'update_mask', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: a.keyword.value not in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=artifactregistryCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the artifactregistry client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/setup.py b/owl-bot-staging/google-cloud-artifact-registry/v1/setup.py deleted file mode 100644 index 3ad6e1d0e59d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/setup.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import io -import os -import re - -import setuptools # type: ignore - -package_root = os.path.abspath(os.path.dirname(__file__)) - -name = 'google-cloud-artifact-registry' - - -description = "Google Cloud Artifact Registry API client library" - -version = None - -with open(os.path.join(package_root, 'google/cloud/artifactregistry/gapic_version.py')) as fp: - version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read()) - assert (len(version_candidates) == 1) - version = version_candidates[0] - -if version[0] == "0": - release_status = "Development Status :: 4 - Beta" -else: - release_status = "Development Status :: 5 - Production/Stable" - -dependencies = [ - "google-api-core[grpc] >= 1.34.1, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", - # Exclude incompatible versions of `google-auth` - # See https://github.com/googleapis/google-cloud-python/issues/12364 - "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", - "proto-plus >= 1.22.3, <2.0.0dev", - "proto-plus >= 1.25.0, <2.0.0dev; python_version >= '3.13'", - "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", - "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", -] -extras = { -} -url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-artifact-registry" - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, "README.rst") -with io.open(readme_filename, encoding="utf-8") as readme_file: - readme = readme_file.read() - -packages = [ - package - for package in setuptools.find_namespace_packages() - if package.startswith("google") -] - -setuptools.setup( - name=name, - version=version, - description=description, - long_description=readme, - author="Google LLC", - author_email="googleapis-packages@google.com", - license="Apache 2.0", - url=url, - classifiers=[ - release_status, - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Operating System :: OS Independent", - "Topic :: Internet", - ], - platforms="Posix; MacOS X; Windows", - packages=packages, - python_requires=">=3.7", - install_requires=dependencies, - extras_require=extras, - include_package_data=True, - zip_safe=False, -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.10.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.10.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.11.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.11.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.12.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.12.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.13.txt b/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.13.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.13.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.7.txt deleted file mode 100644 index a81fb6bcd05c..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.7.txt +++ /dev/null @@ -1,11 +0,0 @@ -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List all library dependencies and extras in this file. -# Pin the version to the lower bound. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", -# Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.34.1 -google-auth==2.14.1 -proto-plus==1.22.3 -protobuf==3.20.2 -grpc-google-iam-v1==0.12.4 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.8.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.8.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.9.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/testing/constraints-3.9.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/tests/__init__.py deleted file mode 100644 index 7b3de3117f38..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/__init__.py deleted file mode 100644 index 7b3de3117f38..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/__init__.py deleted file mode 100644 index 7b3de3117f38..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/artifactregistry_v1/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/artifactregistry_v1/__init__.py deleted file mode 100644 index 7b3de3117f38..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/artifactregistry_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py b/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py deleted file mode 100644 index d1438855f145..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py +++ /dev/null @@ -1,36796 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import os -# try/except added for compatibility with python < 3.8 -try: - from unittest import mock - from unittest.mock import AsyncMock # pragma: NO COVER -except ImportError: # pragma: NO COVER - import mock - -import grpc -from grpc.experimental import aio -from collections.abc import Iterable, AsyncIterable -from google.protobuf import json_format -import json -import math -import pytest -from google.api_core import api_core_version -from proto.marshal.rules.dates import DurationRule, TimestampRule -from proto.marshal.rules import wrappers -from requests import Response -from requests import Request, PreparedRequest -from requests.sessions import Session -from google.protobuf import json_format - -try: - from google.auth.aio import credentials as ga_credentials_async - HAS_GOOGLE_AUTH_AIO = True -except ImportError: # pragma: NO COVER - HAS_GOOGLE_AUTH_AIO = False - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.artifactregistry_v1.services.artifact_registry import ArtifactRegistryAsyncClient -from google.cloud.artifactregistry_v1.services.artifact_registry import ArtifactRegistryClient -from google.cloud.artifactregistry_v1.services.artifact_registry import pagers -from google.cloud.artifactregistry_v1.services.artifact_registry import transports -from google.cloud.artifactregistry_v1.types import apt_artifact -from google.cloud.artifactregistry_v1.types import artifact -from google.cloud.artifactregistry_v1.types import attachment -from google.cloud.artifactregistry_v1.types import attachment as gda_attachment -from google.cloud.artifactregistry_v1.types import file -from google.cloud.artifactregistry_v1.types import file as gda_file -from google.cloud.artifactregistry_v1.types import package -from google.cloud.artifactregistry_v1.types import package as gda_package -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 rule -from google.cloud.artifactregistry_v1.types import rule as gda_rule -from google.cloud.artifactregistry_v1.types import service -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 -from google.cloud.artifactregistry_v1.types import version as gda_version -from google.cloud.artifactregistry_v1.types import vpcsc_config -from google.cloud.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config -from google.cloud.artifactregistry_v1.types import yum_artifact -from google.cloud.location import locations_pb2 -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import options_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.longrunning import operations_pb2 # type: ignore -from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -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 -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import expr_pb2 # type: ignore -import google.auth - - -async def mock_async_gen(data, chunk_size=1): - for i in range(0, len(data)): # pragma: NO COVER - chunk = data[i : i + chunk_size] - yield chunk.encode("utf-8") - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - -# TODO: use async auth anon credentials by default once the minimum version of google-auth is upgraded. -# See related issue: https://github.com/googleapis/gapic-generator-python/issues/2107. -def async_anonymous_credentials(): - if HAS_GOOGLE_AUTH_AIO: - return ga_credentials_async.AnonymousCredentials() - return ga_credentials.AnonymousCredentials() - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - -# If default endpoint template is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint template so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint_template(client): - return "test.{UNIVERSE_DOMAIN}" if ("localhost" in client._DEFAULT_ENDPOINT_TEMPLATE) else client._DEFAULT_ENDPOINT_TEMPLATE - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert ArtifactRegistryClient._get_default_mtls_endpoint(None) is None - assert ArtifactRegistryClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert ArtifactRegistryClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert ArtifactRegistryClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert ArtifactRegistryClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert ArtifactRegistryClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - -def test__read_environment_variables(): - assert ArtifactRegistryClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - assert ArtifactRegistryClient._read_environment_variables() == (True, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - ArtifactRegistryClient._read_environment_variables() - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "never", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "always", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - ArtifactRegistryClient._read_environment_variables() - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - with mock.patch.dict(os.environ, {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": "foo.com"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "auto", "foo.com") - -def test__get_client_cert_source(): - mock_provided_cert_source = mock.Mock() - mock_default_cert_source = mock.Mock() - - assert ArtifactRegistryClient._get_client_cert_source(None, False) is None - assert ArtifactRegistryClient._get_client_cert_source(mock_provided_cert_source, False) is None - assert ArtifactRegistryClient._get_client_cert_source(mock_provided_cert_source, True) == mock_provided_cert_source - - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_default_cert_source): - assert ArtifactRegistryClient._get_client_cert_source(None, True) is mock_default_cert_source - assert ArtifactRegistryClient._get_client_cert_source(mock_provided_cert_source, "true") is mock_provided_cert_source - -@mock.patch.object(ArtifactRegistryClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryAsyncClient)) -def test__get_api_endpoint(): - api_override = "foo.com" - mock_client_cert_source = mock.Mock() - default_universe = ArtifactRegistryClient._DEFAULT_UNIVERSE - default_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) - mock_universe = "bar.com" - mock_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) - - assert ArtifactRegistryClient._get_api_endpoint(api_override, mock_client_cert_source, default_universe, "always") == api_override - assert ArtifactRegistryClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "auto") == ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - assert ArtifactRegistryClient._get_api_endpoint(None, None, default_universe, "auto") == default_endpoint - assert ArtifactRegistryClient._get_api_endpoint(None, None, default_universe, "always") == ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - assert ArtifactRegistryClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "always") == ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - assert ArtifactRegistryClient._get_api_endpoint(None, None, mock_universe, "never") == mock_endpoint - assert ArtifactRegistryClient._get_api_endpoint(None, None, default_universe, "never") == default_endpoint - - with pytest.raises(MutualTLSChannelError) as excinfo: - ArtifactRegistryClient._get_api_endpoint(None, mock_client_cert_source, mock_universe, "auto") - assert str(excinfo.value) == "mTLS is not supported in any universe other than googleapis.com." - - -def test__get_universe_domain(): - client_universe_domain = "foo.com" - universe_domain_env = "bar.com" - - assert ArtifactRegistryClient._get_universe_domain(client_universe_domain, universe_domain_env) == client_universe_domain - assert ArtifactRegistryClient._get_universe_domain(None, universe_domain_env) == universe_domain_env - assert ArtifactRegistryClient._get_universe_domain(None, None) == ArtifactRegistryClient._DEFAULT_UNIVERSE - - with pytest.raises(ValueError) as excinfo: - ArtifactRegistryClient._get_universe_domain("", None) - assert str(excinfo.value) == "Universe Domain cannot be an empty string." - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest"), -]) -def test__validate_universe_domain(client_class, transport_class, transport_name): - client = client_class( - transport=transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) - ) - assert client._validate_universe_domain() == True - - # Test the case when universe is already validated. - assert client._validate_universe_domain() == True - - if transport_name == "grpc": - # Test the case where credentials are provided by the - # `local_channel_credentials`. The default universes in both match. - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - client = client_class(transport=transport_class(channel=channel)) - assert client._validate_universe_domain() == True - - # Test the case where credentials do not exist: e.g. a transport is provided - # with no credentials. Validation should still succeed because there is no - # mismatch with non-existent credentials. - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - transport=transport_class(channel=channel) - transport._credentials = None - client = client_class(transport=transport) - assert client._validate_universe_domain() == True - - # TODO: This is needed to cater for older versions of google-auth - # Make this test unconditional once the minimum supported version of - # google-auth becomes 2.23.0 or higher. - google_auth_major, google_auth_minor = [int(part) for part in google.auth.__version__.split(".")[0:2]] - if google_auth_major > 2 or (google_auth_major == 2 and google_auth_minor >= 23): - credentials = ga_credentials.AnonymousCredentials() - credentials._universe_domain = "foo.com" - # Test the case when there is a universe mismatch from the credentials. - client = client_class( - transport=transport_class(credentials=credentials) - ) - with pytest.raises(ValueError) as excinfo: - client._validate_universe_domain() - assert str(excinfo.value) == "The configured universe domain (googleapis.com) does not match the universe domain found in the credentials (foo.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default." - - # Test the case when there is a universe mismatch from the client. - # - # TODO: Make this test unconditional once the minimum supported version of - # google-api-core becomes 2.15.0 or higher. - api_core_major, api_core_minor = [int(part) for part in api_core_version.__version__.split(".")[0:2]] - if api_core_major > 2 or (api_core_major == 2 and api_core_minor >= 15): - client = client_class(client_options={"universe_domain": "bar.com"}, transport=transport_class(credentials=ga_credentials.AnonymousCredentials(),)) - with pytest.raises(ValueError) as excinfo: - client._validate_universe_domain() - assert str(excinfo.value) == "The configured universe domain (bar.com) does not match the universe domain found in the credentials (googleapis.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default." - - # Test that ValueError is raised if universe_domain is provided via client options and credentials is None - with pytest.raises(ValueError): - client._compare_universes("foo.bar", None) - - -@pytest.mark.parametrize("client_class,transport_name", [ - (ArtifactRegistryClient, "grpc"), - (ArtifactRegistryAsyncClient, "grpc_asyncio"), - (ArtifactRegistryClient, "rest"), -]) -def test_artifact_registry_client_from_service_account_info(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info, transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'artifactregistry.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://artifactregistry.googleapis.com' - ) - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.ArtifactRegistryGrpcTransport, "grpc"), - (transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio"), - (transports.ArtifactRegistryRestTransport, "rest"), -]) -def test_artifact_registry_client_service_account_always_use_jwt(transport_class, transport_name): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize("client_class,transport_name", [ - (ArtifactRegistryClient, "grpc"), - (ArtifactRegistryAsyncClient, "grpc_asyncio"), - (ArtifactRegistryClient, "rest"), -]) -def test_artifact_registry_client_from_service_account_file(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'artifactregistry.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://artifactregistry.googleapis.com' - ) - - -def test_artifact_registry_client_get_transport_class(): - transport = ArtifactRegistryClient.get_transport_class() - available_transports = [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryRestTransport, - ] - assert transport in available_transports - - transport = ArtifactRegistryClient.get_transport_class("grpc") - assert transport == transports.ArtifactRegistryGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc"), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest"), -]) -@mock.patch.object(ArtifactRegistryClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryAsyncClient)) -def test_artifact_registry_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(ArtifactRegistryClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(ArtifactRegistryClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - client = client_class(transport=transport_name) - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - client = client_class(transport=transport_name) - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - # Check the case api_endpoint is provided - options = client_options.ClientOptions(api_audience="https://language.googleapis.com") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience="https://language.googleapis.com" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc", "true"), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc", "false"), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio", "false"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest", "true"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest", "false"), -]) -@mock.patch.object(ArtifactRegistryClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_artifact_registry_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE) - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE) - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - ArtifactRegistryClient, ArtifactRegistryAsyncClient -]) -@mock.patch.object(ArtifactRegistryClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ArtifactRegistryAsyncClient)) -def test_artifact_registry_client_get_mtls_endpoint_and_cert_source(client_class): - mock_client_cert_source = mock.Mock() - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source == mock_client_cert_source - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - mock_client_cert_source = mock.Mock() - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_client_cert_source): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source == mock_client_cert_source - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - client_class.get_mtls_endpoint_and_cert_source() - - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - client_class.get_mtls_endpoint_and_cert_source() - - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - -@pytest.mark.parametrize("client_class", [ - ArtifactRegistryClient, ArtifactRegistryAsyncClient -]) -@mock.patch.object(ArtifactRegistryClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryAsyncClient)) -def test_artifact_registry_client_client_api_endpoint(client_class): - mock_client_cert_source = client_cert_source_callback - api_override = "foo.com" - default_universe = ArtifactRegistryClient._DEFAULT_UNIVERSE - default_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) - mock_universe = "bar.com" - mock_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) - - # If ClientOptions.api_endpoint is set and GOOGLE_API_USE_CLIENT_CERTIFICATE="true", - # use ClientOptions.api_endpoint as the api endpoint regardless. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"): - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=api_override) - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == api_override - - # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="never", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - client = client_class(credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == default_endpoint - - # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="always", - # use the DEFAULT_MTLS_ENDPOINT as the api endpoint. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - client = client_class(credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - - # If ClientOptions.api_endpoint is not set, GOOGLE_API_USE_MTLS_ENDPOINT="auto" (default), - # GOOGLE_API_USE_CLIENT_CERTIFICATE="false" (default), default cert source doesn't exist, - # and ClientOptions.universe_domain="bar.com", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with universe domain as the api endpoint. - options = client_options.ClientOptions() - universe_exists = hasattr(options, "universe_domain") - if universe_exists: - options = client_options.ClientOptions(universe_domain=mock_universe) - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - else: - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == (mock_endpoint if universe_exists else default_endpoint) - assert client.universe_domain == (mock_universe if universe_exists else default_universe) - - # If ClientOptions does not have a universe domain attribute and GOOGLE_API_USE_MTLS_ENDPOINT="never", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. - options = client_options.ClientOptions() - if hasattr(options, "universe_domain"): - delattr(options, "universe_domain") - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == default_endpoint - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc"), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest"), -]) -def test_artifact_registry_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc", grpc_helpers), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest", None), -]) -def test_artifact_registry_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -def test_artifact_registry_client_client_options_from_dict(): - with mock.patch('google.cloud.artifactregistry_v1.services.artifact_registry.transports.ArtifactRegistryGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = ArtifactRegistryClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc", grpc_helpers), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_artifact_registry_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # test that the credentials from file are saved and used as the credentials. - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel" - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - file_creds = ga_credentials.AnonymousCredentials() - load_creds.return_value = (file_creds, None) - adc.return_value = (creds, None) - client = client_class(client_options=options, transport=transport_name) - create_channel.assert_called_with( - "artifactregistry.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', -), - scopes=None, - default_host="artifactregistry.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("request_type", [ - artifact.ListDockerImagesRequest, - dict, -]) -def test_list_docker_images(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_docker_images), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListDockerImagesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_docker_images(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = artifact.ListDockerImagesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDockerImagesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_docker_images_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = artifact.ListDockerImagesRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_docker_images(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == artifact.ListDockerImagesRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - ) - -def test_list_docker_images_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_docker_images in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_docker_images] = mock_rpc - request = {} - client.list_docker_images(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_docker_images(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_docker_images_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_docker_images in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_docker_images] = mock_rpc - - request = {} - await client.list_docker_images(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_docker_images(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_docker_images_async(transport: str = 'grpc_asyncio', request_type=artifact.ListDockerImagesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_docker_images), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListDockerImagesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_docker_images(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = artifact.ListDockerImagesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDockerImagesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_docker_images_async_from_dict(): - await test_list_docker_images_async(request_type=dict) - -def test_list_docker_images_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 = artifact.ListDockerImagesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__') as call: - call.return_value = artifact.ListDockerImagesResponse() - client.list_docker_images(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_docker_images_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = artifact.ListDockerImagesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListDockerImagesResponse()) - await client.list_docker_images(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_docker_images_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_docker_images), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListDockerImagesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_docker_images( - 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_docker_images_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_docker_images( - artifact.ListDockerImagesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_docker_images_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListDockerImagesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListDockerImagesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_docker_images( - 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_docker_images_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_docker_images( - artifact.ListDockerImagesRequest(), - parent='parent_value', - ) - - -def test_list_docker_images_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_docker_images), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - artifact.DockerImage(), - ], - next_page_token='abc', - ), - artifact.ListDockerImagesResponse( - docker_images=[], - next_page_token='def', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - ], - next_page_token='ghi', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_docker_images(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.DockerImage) - for i in results) -def test_list_docker_images_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_docker_images), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - artifact.DockerImage(), - ], - next_page_token='abc', - ), - artifact.ListDockerImagesResponse( - docker_images=[], - next_page_token='def', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - ], - next_page_token='ghi', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - ], - ), - RuntimeError, - ) - pages = list(client.list_docker_images(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_docker_images_async_pager(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - artifact.DockerImage(), - ], - next_page_token='abc', - ), - artifact.ListDockerImagesResponse( - docker_images=[], - next_page_token='def', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - ], - next_page_token='ghi', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_docker_images(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.DockerImage) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_docker_images_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - artifact.DockerImage(), - ], - next_page_token='abc', - ), - artifact.ListDockerImagesResponse( - docker_images=[], - next_page_token='def', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - ], - next_page_token='ghi', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_docker_images(request={}) - ).pages: - 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.GetDockerImageRequest, - dict, -]) -def test_get_docker_image(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_docker_image), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.DockerImage( - name='name_value', - uri='uri_value', - tags=['tags_value'], - image_size_bytes=1699, - media_type='media_type_value', - ) - response = client.get_docker_image(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = artifact.GetDockerImageRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, artifact.DockerImage) - assert response.name == 'name_value' - assert response.uri == 'uri_value' - assert response.tags == ['tags_value'] - assert response.image_size_bytes == 1699 - assert response.media_type == 'media_type_value' - - -def test_get_docker_image_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = artifact.GetDockerImageRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_docker_image), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_docker_image(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == artifact.GetDockerImageRequest( - name='name_value', - ) - -def test_get_docker_image_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_docker_image in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_docker_image] = mock_rpc - request = {} - client.get_docker_image(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_docker_image(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_docker_image_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_docker_image in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_docker_image] = mock_rpc - - request = {} - await client.get_docker_image(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_docker_image(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_docker_image_async(transport: str = 'grpc_asyncio', request_type=artifact.GetDockerImageRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_docker_image), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(artifact.DockerImage( - name='name_value', - uri='uri_value', - tags=['tags_value'], - image_size_bytes=1699, - media_type='media_type_value', - )) - response = await client.get_docker_image(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = artifact.GetDockerImageRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, artifact.DockerImage) - assert response.name == 'name_value' - assert response.uri == 'uri_value' - assert response.tags == ['tags_value'] - assert response.image_size_bytes == 1699 - assert response.media_type == 'media_type_value' - - -@pytest.mark.asyncio -async def test_get_docker_image_async_from_dict(): - await test_get_docker_image_async(request_type=dict) - -def test_get_docker_image_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 = artifact.GetDockerImageRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_docker_image), - '__call__') as call: - call.return_value = artifact.DockerImage() - client.get_docker_image(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_docker_image_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = artifact.GetDockerImageRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_docker_image), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.DockerImage()) - await client.get_docker_image(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_docker_image_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_docker_image), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.DockerImage() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_docker_image( - 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_docker_image_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_docker_image( - artifact.GetDockerImageRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_docker_image_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_docker_image), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.DockerImage() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.DockerImage()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_docker_image( - 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_docker_image_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_docker_image( - artifact.GetDockerImageRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - artifact.ListMavenArtifactsRequest, - dict, -]) -def test_list_maven_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_maven_artifacts), - '__call__') as call: - # Designate an appropriate return value for the call. - 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] - request = artifact.ListMavenArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMavenArtifactsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_maven_artifacts_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = artifact.ListMavenArtifactsRequest( - parent='parent_value', - page_token='page_token_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_maven_artifacts), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_maven_artifacts(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == artifact.ListMavenArtifactsRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_maven_artifacts_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_maven_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_maven_artifacts] = mock_rpc - request = {} - client.list_maven_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_maven_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_maven_artifacts_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_maven_artifacts in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_maven_artifacts] = mock_rpc - - request = {} - await client.list_maven_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_maven_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_maven_artifacts_async(transport: str = 'grpc_asyncio', request_type=artifact.ListMavenArtifactsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_maven_artifacts), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListMavenArtifactsResponse( - next_page_token='next_page_token_value', - )) - 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] - request = artifact.ListMavenArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMavenArtifactsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_maven_artifacts_async_from_dict(): - await test_list_maven_artifacts_async(request_type=dict) - -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 = 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.list_maven_artifacts), - '__call__') as call: - 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 - _, 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_maven_artifacts_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = 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.list_maven_artifacts), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListMavenArtifactsResponse()) - 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] == 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_maven_artifacts_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_maven_artifacts), - '__call__') as call: - # Designate an appropriate return value for the call. - 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 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_maven_artifacts_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_maven_artifacts( - artifact.ListMavenArtifactsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_maven_artifacts_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - 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(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', - ) - - # 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_maven_artifacts_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - -def test_list_maven_artifacts_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_maven_artifacts), - '__call__') 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_maven_artifacts(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.MavenArtifact) - for i in results) -def test_list_maven_artifacts_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_maven_artifacts), - '__call__') 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 = list(client.list_maven_artifacts(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_maven_artifacts_async_pager(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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, - ) - 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_maven_artifacts_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_maven_artifacts(request={}) - ).pages: - 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] - request = artifact.GetMavenArtifactRequest() - assert args[0] == request - - # 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_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = artifact.GetMavenArtifactRequest( - name='name_value', - ) - - # 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: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_maven_artifact(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == artifact.GetMavenArtifactRequest( - name='name_value', - ) - -def test_get_maven_artifact_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_maven_artifact in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_maven_artifact] = mock_rpc - request = {} - client.get_maven_artifact(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_maven_artifact(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_maven_artifact_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_maven_artifact in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_maven_artifact] = mock_rpc - - request = {} - await client.get_maven_artifact(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_maven_artifact(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_maven_artifact_async(transport: str = 'grpc_asyncio', request_type=artifact.GetMavenArtifactRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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 =grpc_helpers_async.FakeUnaryUnaryCall(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.get_maven_artifact(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = artifact.GetMavenArtifactRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_get_maven_artifact_async_from_dict(): - await test_get_maven_artifact_async(request_type=dict) - -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 = artifact.GetMavenArtifactRequest() - - request.name = 'name_value' - - # 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: - 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 - _, 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_maven_artifact_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = artifact.GetMavenArtifactRequest() - - request.name = 'name_value' - - # 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: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.MavenArtifact()) - 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] == 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_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.get_maven_artifact), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.MavenArtifact() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - 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].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_maven_artifact_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_maven_artifact( - artifact.GetMavenArtifactRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_maven_artifact_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.MavenArtifact()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - 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].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_maven_artifact_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_maven_artifact( - artifact.GetMavenArtifactRequest(), - name='name_value', - ) - - -@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, - ) - - # 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_npm_packages), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListNpmPackagesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_npm_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = artifact.ListNpmPackagesRequest() - assert args[0] == request - - # 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_npm_packages_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = artifact.ListNpmPackagesRequest( - parent='parent_value', - page_token='page_token_value', - ) - - # 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: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_npm_packages(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == artifact.ListNpmPackagesRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_npm_packages_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_npm_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_npm_packages] = mock_rpc - request = {} - client.list_npm_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_npm_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_npm_packages_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_npm_packages in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_npm_packages] = mock_rpc - - request = {} - await client.list_npm_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_npm_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_npm_packages_async(transport: str = 'grpc_asyncio', request_type=artifact.ListNpmPackagesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_npm_packages), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListNpmPackagesResponse( - next_page_token='next_page_token_value', - )) - 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] - request = artifact.ListNpmPackagesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListNpmPackagesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_npm_packages_async_from_dict(): - await test_list_npm_packages_async(request_type=dict) - -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 = artifact.ListNpmPackagesRequest() - - request.parent = 'parent_value' - - # 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: - 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 - _, 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_npm_packages_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = artifact.ListNpmPackagesRequest() - - request.parent = 'parent_value' - - # 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: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListNpmPackagesResponse()) - 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] == 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_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.list_npm_packages), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListNpmPackagesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - 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].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_npm_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_npm_packages( - artifact.ListNpmPackagesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_npm_packages_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListNpmPackagesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListNpmPackagesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - 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].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_npm_packages_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_npm_packages( - artifact.ListNpmPackagesRequest(), - parent='parent_value', - ) - - -def test_list_npm_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_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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_npm_packages(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_npm_packages(request={}) - ).pages: - 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, - # 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_npm_package), - '__call__') as call: - # Designate an appropriate return value for the call. - 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] - request = artifact.GetNpmPackageRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - 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_get_npm_package_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = artifact.GetNpmPackageRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_npm_package), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_npm_package(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == artifact.GetNpmPackageRequest( - name='name_value', - ) - -def test_get_npm_package_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_npm_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_npm_package] = mock_rpc - request = {} - client.get_npm_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_npm_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_npm_package_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_npm_package in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_npm_package] = mock_rpc - - request = {} - await client.get_npm_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_npm_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_npm_package_async(transport: str = 'grpc_asyncio', request_type=artifact.GetNpmPackageRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_npm_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(artifact.NpmPackage( - name='name_value', - package_name='package_name_value', - version='version_value', - tags=['tags_value'], - )) - 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] - request = artifact.GetNpmPackageRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - 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_get_npm_package_async_from_dict(): - await test_get_npm_package_async(request_type=dict) - -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 = artifact.GetNpmPackageRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the 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 - _, 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_npm_package_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = artifact.GetNpmPackageRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the 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) - _, 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_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.get_npm_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.NpmPackage() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - 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].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_npm_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_npm_package( - artifact.GetNpmPackageRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_npm_package_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_npm_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.NpmPackage() - - 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.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].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_npm_package_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_npm_package( - artifact.GetNpmPackageRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - artifact.ListPythonPackagesRequest, - dict, -]) -def test_list_python_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_python_packages), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListPythonPackagesResponse( - next_page_token='next_page_token_value', - ) - 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] - request = artifact.ListPythonPackagesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPythonPackagesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_python_packages_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = artifact.ListPythonPackagesRequest( - parent='parent_value', - page_token='page_token_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_python_packages(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == artifact.ListPythonPackagesRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_python_packages_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_python_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_python_packages] = mock_rpc - request = {} - client.list_python_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_python_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_python_packages_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_python_packages in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_python_packages] = mock_rpc - - request = {} - await client.list_python_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_python_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_python_packages_async(transport: str = 'grpc_asyncio', request_type=artifact.ListPythonPackagesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_python_packages), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListPythonPackagesResponse( - next_page_token='next_page_token_value', - )) - 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] - request = artifact.ListPythonPackagesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPythonPackagesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_python_packages_async_from_dict(): - await test_list_python_packages_async(request_type=dict) - -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 = artifact.ListPythonPackagesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), - '__call__') as call: - 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 - _, 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_python_packages_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = artifact.ListPythonPackagesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListPythonPackagesResponse()) - 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] == 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_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.list_python_packages), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListPythonPackagesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - 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].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_python_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_python_packages( - artifact.ListPythonPackagesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_python_packages_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.ListPythonPackagesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListPythonPackagesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - 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].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_python_packages_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_python_packages( - artifact.ListPythonPackagesRequest(), - parent='parent_value', - ) - - -def test_list_python_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_python_packages), - '__call__') 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_python_packages(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.PythonPackage) - for i in results) -def test_list_python_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_python_packages), - '__call__') 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 = 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_list_python_packages_async_pager(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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, - ) - 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=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_python_packages(request={}) - ).pages: - 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] - request = artifact.GetPythonPackageRequest() - assert args[0] == request - - # 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' - - -def test_get_python_package_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = artifact.GetPythonPackageRequest( - name='name_value', - ) - - # 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: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_python_package(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == artifact.GetPythonPackageRequest( - name='name_value', - ) - -def test_get_python_package_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_python_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_python_package] = mock_rpc - request = {} - client.get_python_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_python_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_python_package_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_python_package in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_python_package] = mock_rpc - - request = {} - await client.get_python_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_python_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_python_package_async(transport: str = 'grpc_asyncio', request_type=artifact.GetPythonPackageRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = artifact.GetPythonPackageRequest() - assert args[0] == request - - # 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 = 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.get_python_package), - '__call__') as call: - 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 - _, 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_python_package_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = 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.get_python_package), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.PythonPackage()) - await client.get_python_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_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.get_python_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = artifact.PythonPackage() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_python_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_python_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_python_package( - artifact.GetPythonPackageRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_python_package_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.PythonPackage()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_python_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_python_package_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_python_package( - artifact.GetPythonPackageRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - apt_artifact.ImportAptArtifactsRequest, - dict, -]) -def test_import_apt_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.import_apt_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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = apt_artifact.ImportAptArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_import_apt_artifacts_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = apt_artifact.ImportAptArtifactsRequest( - 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__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.import_apt_artifacts(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == apt_artifact.ImportAptArtifactsRequest( - parent='parent_value', - ) - -def test_import_apt_artifacts_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.import_apt_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.import_apt_artifacts] = mock_rpc - request = {} - client.import_apt_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_apt_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_import_apt_artifacts_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.import_apt_artifacts in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.import_apt_artifacts] = mock_rpc - - request = {} - await client.import_apt_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.import_apt_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_import_apt_artifacts_async(transport: str = 'grpc_asyncio', request_type=apt_artifact.ImportAptArtifactsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_apt_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') - ) - 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] - request = apt_artifact.ImportAptArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_import_apt_artifacts_async_from_dict(): - await test_import_apt_artifacts_async(request_type=dict) - -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 = 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.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 - _, 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_apt_artifacts_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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.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__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - 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] == 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.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.import_yum_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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = yum_artifact.ImportYumArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_import_yum_artifacts_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = yum_artifact.ImportYumArtifactsRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.import_yum_artifacts(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == yum_artifact.ImportYumArtifactsRequest( - parent='parent_value', - ) - -def test_import_yum_artifacts_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.import_yum_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.import_yum_artifacts] = mock_rpc - request = {} - client.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_yum_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_import_yum_artifacts_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.import_yum_artifacts in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.import_yum_artifacts] = mock_rpc - - request = {} - await client.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.import_yum_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_import_yum_artifacts_async(transport: str = 'grpc_asyncio', request_type=yum_artifact.ImportYumArtifactsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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__') 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.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = yum_artifact.ImportYumArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@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( - 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=async_anonymous_credentials(), - ) - - # 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 - - # 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, - ) - - # 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__') as call: - # Designate an appropriate return value for the call. - call.return_value = repository.ListRepositoriesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = repository.ListRepositoriesRequest() - assert args[0] == request - - # 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_repositories_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = repository.ListRepositoriesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_repositories(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == repository.ListRepositoriesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_repositories_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_repositories in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_repositories] = mock_rpc - request = {} - client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_repositories(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_repositories_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_repositories in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_repositories] = mock_rpc - - request = {} - await client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_repositories(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_repositories_async(transport: str = 'grpc_asyncio', request_type=repository.ListRepositoriesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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__') 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', - )) - 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] - request = repository.ListRepositoriesRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = ( - 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_repositories(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, repository.Repository) - for i in results) -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_repositories), - '__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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_repositories(request={}) - ).pages: - 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', - mode=repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - disallow_unspecified_mode=True, - satisfies_pzi=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] - request = repository.GetRepositoryRequest() - assert args[0] == request - - # 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 response.mode == repository.Repository.Mode.STANDARD_REPOSITORY - assert response.size_bytes == 1089 - assert response.satisfies_pzs is True - assert response.cleanup_policy_dry_run is True - assert response.disallow_unspecified_mode is True - assert response.satisfies_pzi is True - - -def test_get_repository_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = repository.GetRepositoryRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_repository(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == repository.GetRepositoryRequest( - name='name_value', - ) - -def test_get_repository_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_repository] = mock_rpc - request = {} - client.get_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_repository_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_repository in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_repository] = mock_rpc - - request = {} - await client.get_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_repository_async(transport: str = 'grpc_asyncio', request_type=repository.GetRepositoryRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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', - mode=repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - disallow_unspecified_mode=True, - satisfies_pzi=True, - )) - 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] - request = repository.GetRepositoryRequest() - assert args[0] == request - - # 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 response.mode == repository.Repository.Mode.STANDARD_REPOSITORY - assert response.size_bytes == 1089 - assert response.satisfies_pzs is True - assert response.cleanup_policy_dry_run is True - assert response.disallow_unspecified_mode is True - assert response.satisfies_pzi is True - - -@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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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] - request = gda_repository.CreateRepositoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_repository_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_repository.CreateRepositoryRequest( - parent='parent_value', - repository_id='repository_id_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_repository(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.CreateRepositoryRequest( - parent='parent_value', - repository_id='repository_id_value', - ) - -def test_create_repository_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_repository] = mock_rpc - request = {} - client.create_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_repository_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_repository in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_repository] = mock_rpc - - request = {} - await client.create_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.create_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_repository_async(transport: str = 'grpc_asyncio', request_type=gda_repository.CreateRepositoryRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = gda_repository.CreateRepositoryRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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', - mode=gda_repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - disallow_unspecified_mode=True, - satisfies_pzi=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] - request = gda_repository.UpdateRepositoryRequest() - assert args[0] == request - - # 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 response.mode == gda_repository.Repository.Mode.STANDARD_REPOSITORY - assert response.size_bytes == 1089 - assert response.satisfies_pzs is True - assert response.cleanup_policy_dry_run is True - assert response.disallow_unspecified_mode is True - assert response.satisfies_pzi is True - - -def test_update_repository_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_repository.UpdateRepositoryRequest( - ) - - # 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_repository(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.UpdateRepositoryRequest( - ) - -def test_update_repository_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_repository] = mock_rpc - request = {} - client.update_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_repository_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_repository in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_repository] = mock_rpc - - request = {} - await client.update_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_repository_async(transport: str = 'grpc_asyncio', request_type=gda_repository.UpdateRepositoryRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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', - mode=gda_repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - disallow_unspecified_mode=True, - satisfies_pzi=True, - )) - 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] - request = gda_repository.UpdateRepositoryRequest() - assert args[0] == request - - # 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 response.mode == gda_repository.Repository.Mode.STANDARD_REPOSITORY - assert response.size_bytes == 1089 - assert response.satisfies_pzs is True - assert response.cleanup_policy_dry_run is True - assert response.disallow_unspecified_mode is True - assert response.satisfies_pzi is True - - -@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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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] - request = repository.DeleteRepositoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_repository_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = repository.DeleteRepositoryRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_repository(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == repository.DeleteRepositoryRequest( - name='name_value', - ) - -def test_delete_repository_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_repository] = mock_rpc - request = {} - client.delete_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_repository_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_repository in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_repository] = mock_rpc - - request = {} - await client.delete_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_repository_async(transport: str = 'grpc_asyncio', request_type=repository.DeleteRepositoryRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = repository.DeleteRepositoryRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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] - request = package.ListPackagesRequest() - assert args[0] == request - - # 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_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = package.ListPackagesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_packages(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == package.ListPackagesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_packages_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_packages] = mock_rpc - request = {} - client.list_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_packages_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_packages in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_packages] = mock_rpc - - request = {} - await client.list_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_packages_async(transport: str = 'grpc_asyncio', request_type=package.ListPackagesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = package.ListPackagesRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_packages(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_packages(request={}) - ).pages: - 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] - request = package.GetPackageRequest() - assert args[0] == request - - # 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_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = package.GetPackageRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_package(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == package.GetPackageRequest( - name='name_value', - ) - -def test_get_package_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_package] = mock_rpc - request = {} - client.get_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_package_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_package in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_package] = mock_rpc - - request = {} - await client.get_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_package_async(transport: str = 'grpc_asyncio', request_type=package.GetPackageRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = package.GetPackageRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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] - request = package.DeletePackageRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_package_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = package.DeletePackageRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_package(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == package.DeletePackageRequest( - name='name_value', - ) - -def test_delete_package_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_package] = mock_rpc - request = {} - client.delete_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_package_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_package in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_package] = mock_rpc - - request = {} - await client.delete_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_package_async(transport: str = 'grpc_asyncio', request_type=package.DeletePackageRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = package.DeletePackageRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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_list_versions(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_versions), - '__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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = version.ListVersionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_versions_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = version.ListVersionsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - filter='filter_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_versions(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == version.ListVersionsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - filter='filter_value', - ) - -def test_list_versions_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_versions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_versions] = mock_rpc - request = {} - client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_versions_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_versions in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_versions] = mock_rpc - - request = {} - await client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_versions_async(transport: str = 'grpc_asyncio', request_type=version.ListVersionsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_versions), - '__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', - )) - 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] - request = version.ListVersionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_versions_async_from_dict(): - await test_list_versions_async(request_type=dict) - -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 = version.ListVersionsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - call.return_value = version.ListVersionsResponse() - client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - 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_versions_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = version.ListVersionsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - call.return_value = 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) - _, 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_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.list_versions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = version.ListVersionsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_versions( - parent='parent_value', - ) - - # 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_versions_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_versions( - version.ListVersionsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_versions_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = version.ListVersionsResponse() - - call.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.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=async_anonymous_credentials(), - ) - - # 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_versions(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_versions(request={}) - ).pages: - 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, - dict, -]) -def test_get_version(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_version), - '__call__') as call: - # Designate an appropriate return value for the call. - 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] - request = version.GetVersionRequest() - assert args[0] == request - - # 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' - - -def test_get_version_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = version.GetVersionRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_version(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == version.GetVersionRequest( - name='name_value', - ) - -def test_get_version_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_version] = mock_rpc - request = {} - client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_version_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_version in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_version] = mock_rpc - - request = {} - await client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_version_async(transport: str = 'grpc_asyncio', request_type=version.GetVersionRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_version), - '__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', - )) - 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] - request = version.GetVersionRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_get_version_async_from_dict(): - await test_get_version_async(request_type=dict) - -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 = version.GetVersionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - call.return_value = version.Version() - client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - 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_version_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = version.GetVersionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.Version()) - await client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - 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_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.get_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = version.Version() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_version( - name='name_value', - ) - - # 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_version_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_version( - version.GetVersionRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_version_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = version.Version() - - call.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.get_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].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_version_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - version.DeleteVersionRequest, - dict, -]) -def test_delete_version(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_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = version.DeleteVersionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_version_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = version.DeleteVersionRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_version(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == version.DeleteVersionRequest( - name='name_value', - ) - -def test_delete_version_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_version] = mock_rpc - request = {} - client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_version_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_version in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_version] = mock_rpc - - request = {} - await client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_version_async(transport: str = 'grpc_asyncio', request_type=version.DeleteVersionRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_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') - ) - 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] - request = version.DeleteVersionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_version_async_from_dict(): - await test_delete_version_async(request_type=dict) - -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.DeleteVersionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - 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_version_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = version.DeleteVersionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - 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] == 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_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_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_version( - name='name_value', - ) - - # 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_version_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_version( - version.DeleteVersionRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_version_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.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_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].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_version_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - version.BatchDeleteVersionsRequest, - dict, -]) -def test_batch_delete_versions(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.batch_delete_versions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.batch_delete_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = version.BatchDeleteVersionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_batch_delete_versions_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = version.BatchDeleteVersionsRequest( - parent='parent_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.batch_delete_versions(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == version.BatchDeleteVersionsRequest( - parent='parent_value', - ) - -def test_batch_delete_versions_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.batch_delete_versions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.batch_delete_versions] = mock_rpc - request = {} - client.batch_delete_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.batch_delete_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_batch_delete_versions_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.batch_delete_versions in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.batch_delete_versions] = mock_rpc - - request = {} - await client.batch_delete_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.batch_delete_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_batch_delete_versions_async(transport: str = 'grpc_asyncio', request_type=version.BatchDeleteVersionsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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.batch_delete_versions), - '__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.batch_delete_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = version.BatchDeleteVersionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_batch_delete_versions_async_from_dict(): - await test_batch_delete_versions_async(request_type=dict) - -def test_batch_delete_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 = version.BatchDeleteVersionsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.batch_delete_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] == 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_batch_delete_versions_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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.BatchDeleteVersionsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.batch_delete_versions(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_batch_delete_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.batch_delete_versions), - '__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.batch_delete_versions( - parent='parent_value', - names=['names_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].names - mock_val = ['names_value'] - assert arg == mock_val - - -def test_batch_delete_versions_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.batch_delete_versions( - version.BatchDeleteVersionsRequest(), - parent='parent_value', - names=['names_value'], - ) - -@pytest.mark.asyncio -async def test_batch_delete_versions_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), - '__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.batch_delete_versions( - parent='parent_value', - names=['names_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].names - mock_val = ['names_value'] - assert arg == mock_val - -@pytest.mark.asyncio -async def test_batch_delete_versions_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.batch_delete_versions( - version.BatchDeleteVersionsRequest(), - parent='parent_value', - names=['names_value'], - ) - - -@pytest.mark.parametrize("request_type", [ - gda_version.UpdateVersionRequest, - dict, -]) -def test_update_version(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_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_version.Version( - name='name_value', - description='description_value', - ) - response = client.update_version(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_version.UpdateVersionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_version.Version) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -def test_update_version_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_version.UpdateVersionRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_version), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_version(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_version.UpdateVersionRequest( - ) - -def test_update_version_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_version] = mock_rpc - request = {} - client.update_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_version_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_version in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_version] = mock_rpc - - request = {} - await client.update_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_version_async(transport: str = 'grpc_asyncio', request_type=gda_version.UpdateVersionRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gda_version.Version( - name='name_value', - description='description_value', - )) - response = await client.update_version(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_version.UpdateVersionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_version.Version) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -@pytest.mark.asyncio -async def test_update_version_async_from_dict(): - await test_update_version_async(request_type=dict) - -def test_update_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 = gda_version.UpdateVersionRequest() - - request.version.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_version), - '__call__') as call: - call.return_value = gda_version.Version() - client.update_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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'version.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_version_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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_version.UpdateVersionRequest() - - request.version.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_version), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_version.Version()) - await client.update_version(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', - 'version.name=name_value', - ) in kw['metadata'] - - -def test_update_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.update_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_version.Version() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_version( - version=gda_version.Version(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].version - mock_val = gda_version.Version(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_version_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_version( - gda_version.UpdateVersionRequest(), - version=gda_version.Version(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_version_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_version.Version() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_version.Version()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_version( - version=gda_version.Version(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].version - mock_val = gda_version.Version(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_version_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_version( - gda_version.UpdateVersionRequest(), - version=gda_version.Version(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - file.ListFilesRequest, - dict, -]) -def test_list_files(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_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = file.ListFilesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_files_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = file.ListFilesRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_value', - order_by='order_by_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_files(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == file.ListFilesRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_value', - order_by='order_by_value', - ) - -def test_list_files_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_files in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_files] = mock_rpc - request = {} - client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_files(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_files_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_files in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_files] = mock_rpc - - request = {} - await client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_files(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_files_async(transport: str = 'grpc_asyncio', request_type=file.ListFilesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(file.ListFilesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = file.ListFilesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesAsyncPager) - 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) - -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 = file.ListFilesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - call.return_value = file.ListFilesResponse() - client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - 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_files_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = file.ListFilesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - call.return_value = 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) - _, 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_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.list_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_files( - parent='parent_value', - ) - - # 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_files_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_files( - file.ListFilesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_files_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse() - - call.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.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=async_anonymous_credentials(), - ) - - # 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_files(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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) - - assert len(responses) == 6 - assert all(isinstance(i, file.File) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_files_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_files(request={}) - ).pages: - 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", [ - file.GetFileRequest, - dict, -]) -def test_get_file(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_file), - '__call__') as call: - # Designate an appropriate return value for the call. - 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] - request = file.GetFileRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -def test_get_file_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = file.GetFileRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_file(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == file.GetFileRequest( - name='name_value', - ) - -def test_get_file_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_file in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_file] = mock_rpc - request = {} - client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_file_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_file in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_file] = mock_rpc - - request = {} - await client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_file_async(transport: str = 'grpc_asyncio', request_type=file.GetFileRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - )) - response = await client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = file.GetFileRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -@pytest.mark.asyncio -async def test_get_file_async_from_dict(): - await test_get_file_async(request_type=dict) - -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 = file.GetFileRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - call.return_value = file.File() - client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - 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_file_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = file.GetFileRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.File()) - await client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - 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_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.get_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.File() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_file( - name='name_value', - ) - - # 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_file_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_file( - file.GetFileRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_file_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.File() - - call.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.get_file( - 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_file_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - file.DeleteFileRequest, - dict, -]) -def test_delete_file(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_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_file(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = file.DeleteFileRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_file_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = file.DeleteFileRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_file), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_file(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == file.DeleteFileRequest( - name='name_value', - ) - -def test_delete_file_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_file in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_file] = mock_rpc - request = {} - client.delete_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_file_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_file in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_file] = mock_rpc - - request = {} - await client.delete_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_file_async(transport: str = 'grpc_asyncio', request_type=file.DeleteFileRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_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') - ) - response = await client.delete_file(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = file.DeleteFileRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_file_async_from_dict(): - await test_delete_file_async(request_type=dict) - -def test_delete_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 = file.DeleteFileRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_file), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_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] == 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_file_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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.DeleteFileRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_file), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_file(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_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_file), - '__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_file( - 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_file_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_file( - file.DeleteFileRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_file_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_file), - '__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_file( - 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_file_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_file( - file.DeleteFileRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_file.UpdateFileRequest, - dict, -]) -def test_update_file(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_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - ) - response = client.update_file(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_file.UpdateFileRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -def test_update_file_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_file.UpdateFileRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_file), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_file(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_file.UpdateFileRequest( - ) - -def test_update_file_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_file in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_file] = mock_rpc - request = {} - client.update_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_file_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_file in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_file] = mock_rpc - - request = {} - await client.update_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_file_async(transport: str = 'grpc_asyncio', request_type=gda_file.UpdateFileRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gda_file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - )) - response = await client.update_file(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_file.UpdateFileRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -@pytest.mark.asyncio -async def test_update_file_async_from_dict(): - await test_update_file_async(request_type=dict) - -def test_update_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 = gda_file.UpdateFileRequest() - - request.file.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_file), - '__call__') as call: - call.return_value = gda_file.File() - client.update_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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'file.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_file_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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_file.UpdateFileRequest() - - request.file.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_file), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_file.File()) - await client.update_file(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', - 'file.name=name_value', - ) in kw['metadata'] - - -def test_update_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.update_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_file.File() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_file( - file=gda_file.File(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].file - mock_val = gda_file.File(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_file_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_file( - gda_file.UpdateFileRequest(), - file=gda_file.File(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_file_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_file.File() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_file.File()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_file( - file=gda_file.File(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].file - mock_val = gda_file.File(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_file_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_file( - gda_file.UpdateFileRequest(), - file=gda_file.File(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - tag.ListTagsRequest, - dict, -]) -def test_list_tags(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_tags), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = tag.ListTagsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_tags_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = tag.ListTagsRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_tags(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tag.ListTagsRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_value', - ) - -def test_list_tags_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_tags in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_tags] = mock_rpc - request = {} - client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_tags(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_tags_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_tags in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_tags] = mock_rpc - - request = {} - await client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_tags(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_tags_async(transport: str = 'grpc_asyncio', request_type=tag.ListTagsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_tags), - '__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', - )) - 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] - request = tag.ListTagsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_tags_async_from_dict(): - await test_list_tags_async(request_type=dict) - -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 = tag.ListTagsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tags), - '__call__') as call: - call.return_value = tag.ListTagsResponse() - client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - 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_tags_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = tag.ListTagsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tags), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.ListTagsResponse()) - 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] == 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_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_tags), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_tags( - parent='parent_value', - ) - - # 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_tags_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_tags( - tag.ListTagsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_tags_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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( - 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_tags_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_tags(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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={},) - 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) - - -@pytest.mark.asyncio -async def test_list_tags_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_tags(request={}) - ).pages: - 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, - dict, -]) -def test_get_tag(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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tag.Tag( - name='name_value', - version='version_value', - ) - response = client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = tag.GetTagRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) - assert response.name == 'name_value' - assert response.version == 'version_value' - - -def test_get_tag_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = tag.GetTagRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_tag(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tag.GetTagRequest( - name='name_value', - ) - -def test_get_tag_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_tag] = mock_rpc - request = {} - client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_tag in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_tag] = mock_rpc - - request = {} - await client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_tag_async(transport: str = 'grpc_asyncio', request_type=tag.GetTagRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag( - name='name_value', - version='version_value', - )) - response = await client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = tag.GetTagRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) - assert response.name == 'name_value' - assert response.version == 'version_value' - - -@pytest.mark.asyncio -async def test_get_tag_async_from_dict(): - await test_get_tag_async(request_type=dict) - -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 = tag.GetTagRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - call.return_value = tag.Tag() - client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_tag_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = tag.GetTagRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag()) - await client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_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: - # Designate an appropriate return value for the call. - call.return_value = tag.Tag() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_tag( - name='name_value', - ) - - # 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_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.get_tag( - tag.GetTagRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_tag_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tag.Tag() - - call.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_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_get_tag_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_tag.CreateTagRequest, - dict, -]) -def test_create_tag(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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag( - name='name_value', - version='version_value', - ) - response = client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_tag.CreateTagRequest() - assert args[0] == request - - # 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' - - -def test_create_tag_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_tag.CreateTagRequest( - parent='parent_value', - tag_id='tag_id_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_tag(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.CreateTagRequest( - parent='parent_value', - tag_id='tag_id_value', - ) - -def test_create_tag_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_tag] = mock_rpc - request = {} - client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_tag in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_tag] = mock_rpc - - request = {} - await client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.create_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_tag_async(transport: str = 'grpc_asyncio', request_type=gda_tag.CreateTagRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_tag.CreateTagRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_create_tag_async_from_dict(): - await test_create_tag_async(request_type=dict) - -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 = gda_tag.CreateTagRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tag), - '__call__') as call: - call.return_value = gda_tag.Tag() - client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_tag_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = gda_tag.CreateTagRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) - await client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_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: - # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_tag( - 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) == 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' - assert arg == mock_val - - -def test_create_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.create_tag( - gda_tag.CreateTagRequest(), - parent='parent_value', - tag=gda_tag.Tag(name='name_value'), - tag_id='tag_id_value', - ) - -@pytest.mark.asyncio -async def test_create_tag_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - # 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_create_tag_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_tag.UpdateTagRequest, - dict, -]) -def test_update_tag(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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag( - name='name_value', - version='version_value', - ) - response = client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_tag.UpdateTagRequest() - assert args[0] == request - - # 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' - - -def test_update_tag_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_tag.UpdateTagRequest( - ) - - # 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_tag(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.UpdateTagRequest( - ) - -def test_update_tag_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_tag] = mock_rpc - request = {} - client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_tag in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_tag] = mock_rpc - - request = {} - await client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_tag_async(transport: str = 'grpc_asyncio', request_type=gda_tag.UpdateTagRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_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.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_tag.UpdateTagRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_update_tag_async_from_dict(): - await test_update_tag_async(request_type=dict) - -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 = gda_tag.UpdateTagRequest() - - request.tag.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tag), - '__call__') as call: - call.return_value = gda_tag.Tag() - client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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', - 'tag.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_tag_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = gda_tag.UpdateTagRequest() - - request.tag.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) - await client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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', - '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=async_anonymous_credentials(), - ) - - # 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 - -@pytest.mark.asyncio -async def test_update_tag_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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']), - ) - - -@pytest.mark.parametrize("request_type", [ - tag.DeleteTagRequest, - dict, -]) -def test_delete_tag(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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = tag.DeleteTagRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_tag_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = tag.DeleteTagRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_tag(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tag.DeleteTagRequest( - name='name_value', - ) - -def test_delete_tag_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_tag] = mock_rpc - request = {} - client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.delete_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_tag in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_tag] = mock_rpc - - request = {} - await client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.delete_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_tag_async(transport: str = 'grpc_asyncio', request_type=tag.DeleteTagRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = tag.DeleteTagRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_tag_async_from_dict(): - await test_delete_tag_async(request_type=dict) - -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 = tag.DeleteTagRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - call.return_value = None - client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_tag_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = tag.DeleteTagRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_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(): - 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=async_anonymous_credentials(), - ) - - # 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.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=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_rule.CreateRuleRequest, - dict, -]) -def test_create_rule(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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_rule.Rule( - name='name_value', - action=gda_rule.Rule.Action.ALLOW, - operation=gda_rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - ) - response = client.create_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_rule.CreateRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_rule.Rule) - assert response.name == 'name_value' - assert response.action == gda_rule.Rule.Action.ALLOW - assert response.operation == gda_rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -def test_create_rule_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_rule.CreateRuleRequest( - parent='parent_value', - rule_id='rule_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_rule), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_rule(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_rule.CreateRuleRequest( - parent='parent_value', - rule_id='rule_id_value', - ) - -def test_create_rule_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_rule in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_rule] = mock_rpc - request = {} - client.create_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_rule_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_rule in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_rule] = mock_rpc - - request = {} - await client.create_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.create_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_rule_async(transport: str = 'grpc_asyncio', request_type=gda_rule.CreateRuleRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule( - name='name_value', - action=gda_rule.Rule.Action.ALLOW, - operation=gda_rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - )) - response = await client.create_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_rule.CreateRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_rule.Rule) - assert response.name == 'name_value' - assert response.action == gda_rule.Rule.Action.ALLOW - assert response.operation == gda_rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -@pytest.mark.asyncio -async def test_create_rule_async_from_dict(): - await test_create_rule_async(request_type=dict) - -def test_create_rule_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_rule.CreateRuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_rule), - '__call__') as call: - call.return_value = gda_rule.Rule() - client.create_rule(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_rule_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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_rule.CreateRuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_rule), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule()) - await client.create_rule(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_rule_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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_rule.Rule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_rule( - parent='parent_value', - rule=gda_rule.Rule(name='name_value'), - rule_id='rule_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].rule - mock_val = gda_rule.Rule(name='name_value') - assert arg == mock_val - arg = args[0].rule_id - mock_val = 'rule_id_value' - assert arg == mock_val - - -def test_create_rule_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_rule( - gda_rule.CreateRuleRequest(), - parent='parent_value', - rule=gda_rule.Rule(name='name_value'), - rule_id='rule_id_value', - ) - -@pytest.mark.asyncio -async def test_create_rule_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_rule.Rule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_rule( - parent='parent_value', - rule=gda_rule.Rule(name='name_value'), - rule_id='rule_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].rule - mock_val = gda_rule.Rule(name='name_value') - assert arg == mock_val - arg = args[0].rule_id - mock_val = 'rule_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_rule_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_rule( - gda_rule.CreateRuleRequest(), - parent='parent_value', - rule=gda_rule.Rule(name='name_value'), - rule_id='rule_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - rule.ListRulesRequest, - dict, -]) -def test_list_rules(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_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = rule.ListRulesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = rule.ListRulesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_rules_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = rule.ListRulesRequest( - parent='parent_value', - page_token='page_token_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_rules(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == rule.ListRulesRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_rules_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_rules in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_rules] = mock_rpc - request = {} - client.list_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_rules(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_rules_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_rules in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_rules] = mock_rpc - - request = {} - await client.list_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_rules(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_rules_async(transport: str = 'grpc_asyncio', request_type=rule.ListRulesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(rule.ListRulesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = rule.ListRulesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRulesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_rules_async_from_dict(): - await test_list_rules_async(request_type=dict) - -def test_list_rules_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 = rule.ListRulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__') as call: - call.return_value = rule.ListRulesResponse() - client.list_rules(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_rules_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = rule.ListRulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(rule.ListRulesResponse()) - await client.list_rules(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_rules_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_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = rule.ListRulesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_rules( - 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_rules_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_rules( - rule.ListRulesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_rules_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = rule.ListRulesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(rule.ListRulesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_rules( - 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_rules_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_rules( - rule.ListRulesRequest(), - parent='parent_value', - ) - - -def test_list_rules_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_rules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - rule.Rule(), - ], - next_page_token='abc', - ), - rule.ListRulesResponse( - rules=[], - next_page_token='def', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - ], - next_page_token='ghi', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_rules(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, rule.Rule) - for i in results) -def test_list_rules_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_rules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - rule.Rule(), - ], - next_page_token='abc', - ), - rule.ListRulesResponse( - rules=[], - next_page_token='def', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - ], - next_page_token='ghi', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_rules(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_rules_async_pager(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - rule.Rule(), - ], - next_page_token='abc', - ), - rule.ListRulesResponse( - rules=[], - next_page_token='def', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - ], - next_page_token='ghi', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_rules(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, rule.Rule) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_rules_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - rule.Rule(), - ], - next_page_token='abc', - ), - rule.ListRulesResponse( - rules=[], - next_page_token='def', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - ], - next_page_token='ghi', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_rules(request={}) - ).pages: - 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", [ - rule.GetRuleRequest, - dict, -]) -def test_get_rule(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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = rule.Rule( - name='name_value', - action=rule.Rule.Action.ALLOW, - operation=rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - ) - response = client.get_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = rule.GetRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, rule.Rule) - assert response.name == 'name_value' - assert response.action == rule.Rule.Action.ALLOW - assert response.operation == rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -def test_get_rule_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = rule.GetRuleRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_rule), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_rule(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == rule.GetRuleRequest( - name='name_value', - ) - -def test_get_rule_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_rule in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_rule] = mock_rpc - request = {} - client.get_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_rule_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_rule in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_rule] = mock_rpc - - request = {} - await client.get_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_rule_async(transport: str = 'grpc_asyncio', request_type=rule.GetRuleRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(rule.Rule( - name='name_value', - action=rule.Rule.Action.ALLOW, - operation=rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - )) - response = await client.get_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = rule.GetRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, rule.Rule) - assert response.name == 'name_value' - assert response.action == rule.Rule.Action.ALLOW - assert response.operation == rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -@pytest.mark.asyncio -async def test_get_rule_async_from_dict(): - await test_get_rule_async(request_type=dict) - -def test_get_rule_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 = rule.GetRuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_rule), - '__call__') as call: - call.return_value = rule.Rule() - client.get_rule(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_rule_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = rule.GetRuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_rule), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(rule.Rule()) - await client.get_rule(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_rule_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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = rule.Rule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_rule( - 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_rule_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_rule( - rule.GetRuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_rule_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = rule.Rule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(rule.Rule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_rule( - 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_rule_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_rule( - rule.GetRuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_rule.UpdateRuleRequest, - dict, -]) -def test_update_rule(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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_rule.Rule( - name='name_value', - action=gda_rule.Rule.Action.ALLOW, - operation=gda_rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - ) - response = client.update_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_rule.UpdateRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_rule.Rule) - assert response.name == 'name_value' - assert response.action == gda_rule.Rule.Action.ALLOW - assert response.operation == gda_rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -def test_update_rule_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_rule.UpdateRuleRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_rule), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_rule(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_rule.UpdateRuleRequest( - ) - -def test_update_rule_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_rule in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_rule] = mock_rpc - request = {} - client.update_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_rule_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_rule in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_rule] = mock_rpc - - request = {} - await client.update_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_rule_async(transport: str = 'grpc_asyncio', request_type=gda_rule.UpdateRuleRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule( - name='name_value', - action=gda_rule.Rule.Action.ALLOW, - operation=gda_rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - )) - response = await client.update_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_rule.UpdateRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_rule.Rule) - assert response.name == 'name_value' - assert response.action == gda_rule.Rule.Action.ALLOW - assert response.operation == gda_rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -@pytest.mark.asyncio -async def test_update_rule_async_from_dict(): - await test_update_rule_async(request_type=dict) - -def test_update_rule_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_rule.UpdateRuleRequest() - - request.rule.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_rule), - '__call__') as call: - call.return_value = gda_rule.Rule() - client.update_rule(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', - 'rule.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_rule_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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_rule.UpdateRuleRequest() - - request.rule.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_rule), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule()) - await client.update_rule(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', - 'rule.name=name_value', - ) in kw['metadata'] - - -def test_update_rule_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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_rule.Rule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_rule( - rule=gda_rule.Rule(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].rule - mock_val = gda_rule.Rule(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_rule_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_rule( - gda_rule.UpdateRuleRequest(), - rule=gda_rule.Rule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_rule_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_rule.Rule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_rule( - rule=gda_rule.Rule(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].rule - mock_val = gda_rule.Rule(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_rule_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_rule( - gda_rule.UpdateRuleRequest(), - rule=gda_rule.Rule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - rule.DeleteRuleRequest, - dict, -]) -def test_delete_rule(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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = rule.DeleteRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_rule_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = rule.DeleteRuleRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_rule), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_rule(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == rule.DeleteRuleRequest( - name='name_value', - ) - -def test_delete_rule_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_rule in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_rule] = mock_rpc - request = {} - client.delete_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.delete_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_rule_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_rule in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_rule] = mock_rpc - - request = {} - await client.delete_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.delete_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_rule_async(transport: str = 'grpc_asyncio', request_type=rule.DeleteRuleRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = rule.DeleteRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_rule_async_from_dict(): - await test_delete_rule_async(request_type=dict) - -def test_delete_rule_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 = rule.DeleteRuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_rule), - '__call__') as call: - call.return_value = None - client.delete_rule(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_rule_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = rule.DeleteRuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_rule), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_rule(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_rule_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_rule), - '__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_rule( - 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_rule_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_rule( - rule.DeleteRuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_rule_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_rule), - '__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_rule( - 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_rule_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_rule( - rule.DeleteRuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.SetIamPolicyRequest, - dict, -]) -def test_set_iam_policy(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.set_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b'etag_blob', - ) - 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] - request = iam_policy_pb2.SetIamPolicyRequest() - assert args[0] == request - - # 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' - - -def test_set_iam_policy_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.SetIamPolicyRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.set_iam_policy(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.SetIamPolicyRequest( - resource='resource_value', - ) - -def test_set_iam_policy_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.set_iam_policy in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.set_iam_policy] = mock_rpc - request = {} - client.set_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.set_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_set_iam_policy_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.set_iam_policy in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.set_iam_policy] = mock_rpc - - request = {} - await client.set_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.set_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_set_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.SetIamPolicyRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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.set_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy( - version=774, - etag=b'etag_blob', - )) - 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] - request = iam_policy_pb2.SetIamPolicyRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_set_iam_policy_async_from_dict(): - await test_set_iam_policy_async(request_type=dict) - -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 = iam_policy_pb2.SetIamPolicyRequest() - - request.resource = 'resource_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy), - '__call__') as call: - call.return_value = policy_pb2.Policy() - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'resource=resource_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_set_iam_policy_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = iam_policy_pb2.SetIamPolicyRequest() - - request.resource = 'resource_value' - - # 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) - - # 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', - 'resource=resource_value', - ) in kw['metadata'] - -def test_set_iam_policy_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: - # 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", [ - iam_policy_pb2.GetIamPolicyRequest, - dict, -]) -def test_get_iam_policy(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_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b'etag_blob', - ) - 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] - request = iam_policy_pb2.GetIamPolicyRequest() - assert args[0] == request - - # 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' - - -def test_get_iam_policy_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.GetIamPolicyRequest( - resource='resource_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_iam_policy(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.GetIamPolicyRequest( - resource='resource_value', - ) - -def test_get_iam_policy_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_iam_policy in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_iam_policy] = mock_rpc - request = {} - client.get_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_iam_policy_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_iam_policy in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_iam_policy] = mock_rpc - - request = {} - await client.get_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.GetIamPolicyRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy( - version=774, - etag=b'etag_blob', - )) - 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] - request = iam_policy_pb2.GetIamPolicyRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_get_iam_policy_async_from_dict(): - await test_get_iam_policy_async(request_type=dict) - -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 = iam_policy_pb2.GetIamPolicyRequest() - - request.resource = 'resource_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy), - '__call__') as call: - call.return_value = policy_pb2.Policy() - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'resource=resource_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_iam_policy_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = iam_policy_pb2.GetIamPolicyRequest() - - request.resource = 'resource_value' - - # 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) - - # 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', - 'resource=resource_value', - ) in kw['metadata'] - -def test_get_iam_policy_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.get_iam_policy), - '__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.assert_called() - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.TestIamPermissionsRequest, - dict, -]) -def test_test_iam_permissions(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.test_iam_permissions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=['permissions_value'], - ) - response = client.test_iam_permissions(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.TestIamPermissionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ['permissions_value'] - - -def test_test_iam_permissions_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.TestIamPermissionsRequest( - resource='resource_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.test_iam_permissions(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.TestIamPermissionsRequest( - resource='resource_value', - ) - -def test_test_iam_permissions_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.test_iam_permissions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.test_iam_permissions] = mock_rpc - request = {} - client.test_iam_permissions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.test_iam_permissions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_test_iam_permissions_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.test_iam_permissions in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.test_iam_permissions] = mock_rpc - - request = {} - await client.test_iam_permissions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.test_iam_permissions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_test_iam_permissions_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.TestIamPermissionsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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.test_iam_permissions), - '__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'], - )) - 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] - request = iam_policy_pb2.TestIamPermissionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ['permissions_value'] - - -@pytest.mark.asyncio -async def test_test_iam_permissions_async_from_dict(): - await test_test_iam_permissions_async(request_type=dict) - -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.TestIamPermissionsRequest() - - request.resource = 'resource_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), - '__call__') as call: - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'resource=resource_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_test_iam_permissions_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = iam_policy_pb2.TestIamPermissionsRequest() - - request.resource = 'resource_value' - - # 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 = 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) - _, 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', - 'resource=resource_value', - ) in kw['metadata'] - -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.test_iam_permissions), - '__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.assert_called() - - -@pytest.mark.parametrize("request_type", [ - settings.GetProjectSettingsRequest, - dict, -]) -def test_get_project_settings(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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - pull_percent=1293, - ) - 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] - request = settings.GetProjectSettingsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) - assert response.name == 'name_value' - assert response.legacy_redirection_state == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - assert response.pull_percent == 1293 - - -def test_get_project_settings_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = settings.GetProjectSettingsRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_project_settings(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == settings.GetProjectSettingsRequest( - name='name_value', - ) - -def test_get_project_settings_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_project_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_project_settings] = mock_rpc - request = {} - client.get_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_project_settings_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_project_settings in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_project_settings] = mock_rpc - - request = {} - await client.get_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_project_settings_async(transport: str = 'grpc_asyncio', request_type=settings.GetProjectSettingsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - pull_percent=1293, - )) - 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] - request = settings.GetProjectSettingsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) - assert response.name == 'name_value' - assert response.legacy_redirection_state == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - assert response.pull_percent == 1293 - - -@pytest.mark.asyncio -async def test_get_project_settings_async_from_dict(): - await test_get_project_settings_async(request_type=dict) - -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 = settings.GetProjectSettingsRequest() - - 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) - - # 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_project_settings_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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.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 = 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) - _, 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_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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - settings.UpdateProjectSettingsRequest, - dict, -]) -def test_update_project_settings(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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - pull_percent=1293, - ) - 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] - request = settings.UpdateProjectSettingsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) - assert response.name == 'name_value' - assert response.legacy_redirection_state == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - assert response.pull_percent == 1293 - - -def test_update_project_settings_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = settings.UpdateProjectSettingsRequest( - ) - - # 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: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_project_settings(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == settings.UpdateProjectSettingsRequest( - ) - -def test_update_project_settings_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_project_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_project_settings] = mock_rpc - request = {} - client.update_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_project_settings_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_project_settings in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_project_settings] = mock_rpc - - request = {} - await client.update_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_project_settings_async(transport: str = 'grpc_asyncio', request_type=settings.UpdateProjectSettingsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - pull_percent=1293, - )) - 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] - request = settings.UpdateProjectSettingsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) - assert response.name == 'name_value' - assert response.legacy_redirection_state == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - assert response.pull_percent == 1293 - - -@pytest.mark.asyncio -async def test_update_project_settings_async_from_dict(): - await test_update_project_settings_async(request_type=dict) - -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 = settings.UpdateProjectSettingsRequest() - - 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.update_project_settings), - '__call__') as call: - 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 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'project_settings.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_project_settings_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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.project_settings.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__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings()) - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'project_settings.name=name_value', - ) in kw['metadata'] - - -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.update_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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']), - ) - - -@pytest.mark.parametrize("request_type", [ - vpcsc_config.GetVPCSCConfigRequest, - dict, -]) -def test_get_vpcsc_config(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_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = vpcsc_config.VPCSCConfig( - name='name_value', - vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) - 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] - request = vpcsc_config.GetVPCSCConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, vpcsc_config.VPCSCConfig) - assert response.name == 'name_value' - assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - - -def test_get_vpcsc_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = vpcsc_config.GetVPCSCConfigRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vpcsc_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_vpcsc_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == vpcsc_config.GetVPCSCConfigRequest( - name='name_value', - ) - -def test_get_vpcsc_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vpcsc_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vpcsc_config] = mock_rpc - request = {} - client.get_vpcsc_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vpcsc_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vpcsc_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_vpcsc_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_vpcsc_config] = mock_rpc - - request = {} - await client.get_vpcsc_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_vpcsc_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vpcsc_config_async(transport: str = 'grpc_asyncio', request_type=vpcsc_config.GetVPCSCConfigRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(vpcsc_config.VPCSCConfig( - name='name_value', - vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - )) - 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] - request = vpcsc_config.GetVPCSCConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, vpcsc_config.VPCSCConfig) - assert response.name == 'name_value' - assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - - -@pytest.mark.asyncio -async def test_get_vpcsc_config_async_from_dict(): - await test_get_vpcsc_config_async(request_type=dict) - -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 = 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_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 - _, 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_vpcsc_config_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = 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_vpcsc_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(vpcsc_config.VPCSCConfig()) - 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] == 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_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_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - 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_vpcsc_config( - 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_vpcsc_config_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_vpcsc_config( - vpcsc_config.GetVPCSCConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_vpcsc_config_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = vpcsc_config.VPCSCConfig() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(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_vpcsc_config( - 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_vpcsc_config_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_vpcsc_config( - vpcsc_config.GetVPCSCConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_vpcsc_config.UpdateVPCSCConfigRequest, - dict, -]) -def test_update_vpcsc_config(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_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_vpcsc_config.VPCSCConfig( - name='name_value', - vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) - 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] - request = gda_vpcsc_config.UpdateVPCSCConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_vpcsc_config.VPCSCConfig) - assert response.name == 'name_value' - assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - - -def test_update_vpcsc_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_vpcsc_config.UpdateVPCSCConfigRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_vpcsc_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_vpcsc_config.UpdateVPCSCConfigRequest( - ) - -def test_update_vpcsc_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_vpcsc_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_vpcsc_config] = mock_rpc - request = {} - client.update_vpcsc_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_vpcsc_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_vpcsc_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_vpcsc_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_vpcsc_config] = mock_rpc - - request = {} - await client.update_vpcsc_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_vpcsc_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_vpcsc_config_async(transport: str = 'grpc_asyncio', request_type=gda_vpcsc_config.UpdateVPCSCConfigRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gda_vpcsc_config.VPCSCConfig( - name='name_value', - vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - )) - 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] - request = gda_vpcsc_config.UpdateVPCSCConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_vpcsc_config.VPCSCConfig) - assert response.name == 'name_value' - assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - - -@pytest.mark.asyncio -async def test_update_vpcsc_config_async_from_dict(): - await test_update_vpcsc_config_async(request_type=dict) - -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 = gda_vpcsc_config.UpdateVPCSCConfigRequest() - - 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_vpcsc_config), - '__call__') as call: - 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 - _, 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', - 'vpcsc_config.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_vpcsc_config_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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_vpcsc_config.UpdateVPCSCConfigRequest() - - 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_vpcsc_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_vpcsc_config.VPCSCConfig()) - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'vpcsc_config.name=name_value', - ) in kw['metadata'] - - -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_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - 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_vpcsc_config( - vpcsc_config=gda_vpcsc_config.VPCSCConfig(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].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_vpcsc_config_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_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_vpcsc_config_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_vpcsc_config.VPCSCConfig() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(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_vpcsc_config( - vpcsc_config=gda_vpcsc_config.VPCSCConfig(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].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 - -@pytest.mark.asyncio -async def test_update_vpcsc_config_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - 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']), - ) - - -@pytest.mark.parametrize("request_type", [ - gda_package.UpdatePackageRequest, - dict, -]) -def test_update_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.update_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_package.Package( - name='name_value', - display_name='display_name_value', - ) - response = client.update_package(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_package.UpdatePackageRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_package.Package) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - - -def test_update_package_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_package.UpdatePackageRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_package), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_package(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_package.UpdatePackageRequest( - ) - -def test_update_package_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_package] = mock_rpc - request = {} - client.update_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_package_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_package in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_package] = mock_rpc - - request = {} - await client.update_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_package_async(transport: str = 'grpc_asyncio', request_type=gda_package.UpdatePackageRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(gda_package.Package( - name='name_value', - display_name='display_name_value', - )) - response = await client.update_package(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_package.UpdatePackageRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_package.Package) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_update_package_async_from_dict(): - await test_update_package_async(request_type=dict) - -def test_update_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_package.UpdatePackageRequest() - - request.package.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_package), - '__call__') as call: - call.return_value = gda_package.Package() - client.update_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', - 'package.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_package_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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_package.UpdatePackageRequest() - - request.package.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_package), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_package.Package()) - await client.update_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', - 'package.name=name_value', - ) in kw['metadata'] - - -def test_update_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.update_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_package.Package() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_package( - package=gda_package.Package(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].package - mock_val = gda_package.Package(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_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.update_package( - gda_package.UpdatePackageRequest(), - package=gda_package.Package(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_package_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_package.Package() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_package.Package()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_package( - package=gda_package.Package(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].package - mock_val = gda_package.Package(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_package_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_package( - gda_package.UpdatePackageRequest(), - package=gda_package.Package(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - attachment.ListAttachmentsRequest, - dict, -]) -def test_list_attachments(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_attachments), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = attachment.ListAttachmentsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_attachments(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = attachment.ListAttachmentsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAttachmentsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_attachments_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = attachment.ListAttachmentsRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_attachments(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == attachment.ListAttachmentsRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_value', - ) - -def test_list_attachments_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_attachments in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_attachments] = mock_rpc - request = {} - client.list_attachments(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_attachments(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_attachments_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_attachments in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_attachments] = mock_rpc - - request = {} - await client.list_attachments(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_attachments(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_attachments_async(transport: str = 'grpc_asyncio', request_type=attachment.ListAttachmentsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_attachments), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(attachment.ListAttachmentsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_attachments(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = attachment.ListAttachmentsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAttachmentsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_attachments_async_from_dict(): - await test_list_attachments_async(request_type=dict) - -def test_list_attachments_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 = attachment.ListAttachmentsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__') as call: - call.return_value = attachment.ListAttachmentsResponse() - client.list_attachments(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_attachments_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = attachment.ListAttachmentsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(attachment.ListAttachmentsResponse()) - await client.list_attachments(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_attachments_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_attachments), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = attachment.ListAttachmentsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_attachments( - 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_attachments_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_attachments( - attachment.ListAttachmentsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_attachments_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = attachment.ListAttachmentsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(attachment.ListAttachmentsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_attachments( - 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_attachments_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_attachments( - attachment.ListAttachmentsRequest(), - parent='parent_value', - ) - - -def test_list_attachments_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_attachments), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - attachment.Attachment(), - ], - next_page_token='abc', - ), - attachment.ListAttachmentsResponse( - attachments=[], - next_page_token='def', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - ], - next_page_token='ghi', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_attachments(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, attachment.Attachment) - for i in results) -def test_list_attachments_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_attachments), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - attachment.Attachment(), - ], - next_page_token='abc', - ), - attachment.ListAttachmentsResponse( - attachments=[], - next_page_token='def', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - ], - next_page_token='ghi', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - ], - ), - RuntimeError, - ) - pages = list(client.list_attachments(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_attachments_async_pager(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - attachment.Attachment(), - ], - next_page_token='abc', - ), - attachment.ListAttachmentsResponse( - attachments=[], - next_page_token='def', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - ], - next_page_token='ghi', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_attachments(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, attachment.Attachment) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_attachments_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - attachment.Attachment(), - ], - next_page_token='abc', - ), - attachment.ListAttachmentsResponse( - attachments=[], - next_page_token='def', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - ], - next_page_token='ghi', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_attachments(request={}) - ).pages: - 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", [ - attachment.GetAttachmentRequest, - dict, -]) -def test_get_attachment(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_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = attachment.Attachment( - name='name_value', - target='target_value', - type_='type__value', - attachment_namespace='attachment_namespace_value', - files=['files_value'], - oci_version_name='oci_version_name_value', - ) - response = client.get_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = attachment.GetAttachmentRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, attachment.Attachment) - assert response.name == 'name_value' - assert response.target == 'target_value' - assert response.type_ == 'type__value' - assert response.attachment_namespace == 'attachment_namespace_value' - assert response.files == ['files_value'] - assert response.oci_version_name == 'oci_version_name_value' - - -def test_get_attachment_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = attachment.GetAttachmentRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_attachment), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_attachment(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == attachment.GetAttachmentRequest( - name='name_value', - ) - -def test_get_attachment_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_attachment in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_attachment] = mock_rpc - request = {} - client.get_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_attachment_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_attachment in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_attachment] = mock_rpc - - request = {} - await client.get_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_attachment_async(transport: str = 'grpc_asyncio', request_type=attachment.GetAttachmentRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(attachment.Attachment( - name='name_value', - target='target_value', - type_='type__value', - attachment_namespace='attachment_namespace_value', - files=['files_value'], - oci_version_name='oci_version_name_value', - )) - response = await client.get_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = attachment.GetAttachmentRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, attachment.Attachment) - assert response.name == 'name_value' - assert response.target == 'target_value' - assert response.type_ == 'type__value' - assert response.attachment_namespace == 'attachment_namespace_value' - assert response.files == ['files_value'] - assert response.oci_version_name == 'oci_version_name_value' - - -@pytest.mark.asyncio -async def test_get_attachment_async_from_dict(): - await test_get_attachment_async(request_type=dict) - -def test_get_attachment_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 = attachment.GetAttachmentRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_attachment), - '__call__') as call: - call.return_value = attachment.Attachment() - client.get_attachment(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_attachment_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = attachment.GetAttachmentRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_attachment), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(attachment.Attachment()) - await client.get_attachment(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_attachment_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_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = attachment.Attachment() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_attachment( - 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_attachment_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_attachment( - attachment.GetAttachmentRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_attachment_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = attachment.Attachment() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(attachment.Attachment()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_attachment( - 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_attachment_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_attachment( - attachment.GetAttachmentRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_attachment.CreateAttachmentRequest, - dict, -]) -def test_create_attachment(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_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_attachment.CreateAttachmentRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_attachment_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_attachment.CreateAttachmentRequest( - parent='parent_value', - attachment_id='attachment_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_attachment), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_attachment(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_attachment.CreateAttachmentRequest( - parent='parent_value', - attachment_id='attachment_id_value', - ) - -def test_create_attachment_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_attachment in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_attachment] = mock_rpc - request = {} - client.create_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_attachment_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_attachment in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_attachment] = mock_rpc - - request = {} - await client.create_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.create_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_attachment_async(transport: str = 'grpc_asyncio', request_type=gda_attachment.CreateAttachmentRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_attachment), - '__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_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_attachment.CreateAttachmentRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_attachment_async_from_dict(): - await test_create_attachment_async(request_type=dict) - -def test_create_attachment_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_attachment.CreateAttachmentRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_attachment), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_attachment(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_attachment_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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_attachment.CreateAttachmentRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_attachment), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_attachment(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_attachment_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_attachment), - '__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_attachment( - parent='parent_value', - attachment=gda_attachment.Attachment(name='name_value'), - attachment_id='attachment_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].attachment - mock_val = gda_attachment.Attachment(name='name_value') - assert arg == mock_val - arg = args[0].attachment_id - mock_val = 'attachment_id_value' - assert arg == mock_val - - -def test_create_attachment_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_attachment( - gda_attachment.CreateAttachmentRequest(), - parent='parent_value', - attachment=gda_attachment.Attachment(name='name_value'), - attachment_id='attachment_id_value', - ) - -@pytest.mark.asyncio -async def test_create_attachment_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_attachment), - '__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_attachment( - parent='parent_value', - attachment=gda_attachment.Attachment(name='name_value'), - attachment_id='attachment_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].attachment - mock_val = gda_attachment.Attachment(name='name_value') - assert arg == mock_val - arg = args[0].attachment_id - mock_val = 'attachment_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_attachment_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_attachment( - gda_attachment.CreateAttachmentRequest(), - parent='parent_value', - attachment=gda_attachment.Attachment(name='name_value'), - attachment_id='attachment_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - attachment.DeleteAttachmentRequest, - dict, -]) -def test_delete_attachment(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_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = attachment.DeleteAttachmentRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_attachment_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = attachment.DeleteAttachmentRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_attachment), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_attachment(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == attachment.DeleteAttachmentRequest( - name='name_value', - ) - -def test_delete_attachment_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_attachment in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_attachment] = mock_rpc - request = {} - client.delete_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_attachment_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_attachment in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_attachment] = mock_rpc - - request = {} - await client.delete_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_attachment_async(transport: str = 'grpc_asyncio', request_type=attachment.DeleteAttachmentRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_attachment), - '__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_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = attachment.DeleteAttachmentRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_attachment_async_from_dict(): - await test_delete_attachment_async(request_type=dict) - -def test_delete_attachment_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 = attachment.DeleteAttachmentRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_attachment), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_attachment(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_attachment_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = attachment.DeleteAttachmentRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_attachment), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_attachment(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_attachment_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_attachment), - '__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_attachment( - 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_attachment_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_attachment( - attachment.DeleteAttachmentRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_attachment_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_attachment), - '__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_attachment( - 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_attachment_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_attachment( - attachment.DeleteAttachmentRequest(), - name='name_value', - ) - - -def test_list_docker_images_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_docker_images in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_docker_images] = mock_rpc - - request = {} - client.list_docker_images(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_docker_images(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_docker_images_rest_required_fields(request_type=artifact.ListDockerImagesRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_docker_images._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_docker_images._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.ListDockerImagesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListDockerImagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_docker_images(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_docker_images_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_docker_images._get_unset_required_fields({}) - assert set(unset_fields) == (set(("orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_docker_images_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListDockerImagesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.ListDockerImagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_docker_images(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/dockerImages" % client.transport._host, args[1]) - - -def test_list_docker_images_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_docker_images( - artifact.ListDockerImagesRequest(), - parent='parent_value', - ) - - -def test_list_docker_images_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - artifact.DockerImage(), - ], - next_page_token='abc', - ), - artifact.ListDockerImagesResponse( - docker_images=[], - next_page_token='def', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - ], - next_page_token='ghi', - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(artifact.ListDockerImagesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_docker_images(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.DockerImage) - for i in results) - - pages = list(client.list_docker_images(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_docker_image_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_docker_image in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_docker_image] = mock_rpc - - request = {} - client.get_docker_image(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_docker_image(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_docker_image_rest_required_fields(request_type=artifact.GetDockerImageRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_docker_image._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_docker_image._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.DockerImage() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.DockerImage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_docker_image(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_docker_image_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_docker_image._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_docker_image_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.DockerImage() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.DockerImage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_docker_image(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/dockerImages/*}" % client.transport._host, args[1]) - - -def test_get_docker_image_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_docker_image( - artifact.GetDockerImageRequest(), - name='name_value', - ) - - -def test_list_maven_artifacts_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_maven_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_maven_artifacts] = mock_rpc - - request = {} - client.list_maven_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_maven_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_maven_artifacts_rest_required_fields(request_type=artifact.ListMavenArtifactsRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_maven_artifacts._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_maven_artifacts._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.ListMavenArtifactsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListMavenArtifactsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_maven_artifacts(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_maven_artifacts_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_maven_artifacts._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_maven_artifacts_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListMavenArtifactsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.ListMavenArtifactsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_maven_artifacts(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/mavenArtifacts" % client.transport._host, args[1]) - - -def test_list_maven_artifacts_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_maven_artifacts_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(artifact.ListMavenArtifactsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_maven_artifacts(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.MavenArtifact) - for i in results) - - pages = list(client.list_maven_artifacts(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_maven_artifact_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_maven_artifact in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_maven_artifact] = mock_rpc - - request = {} - client.get_maven_artifact(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_maven_artifact(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_maven_artifact_rest_required_fields(request_type=artifact.GetMavenArtifactRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_maven_artifact._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_maven_artifact._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.MavenArtifact() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.MavenArtifact.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_maven_artifact(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_maven_artifact_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_maven_artifact._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_maven_artifact_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.MavenArtifact() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.MavenArtifact.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_maven_artifact(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/mavenArtifacts/*}" % client.transport._host, args[1]) - - -def test_get_maven_artifact_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_maven_artifact( - artifact.GetMavenArtifactRequest(), - name='name_value', - ) - - -def test_list_npm_packages_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_npm_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_npm_packages] = mock_rpc - - request = {} - client.list_npm_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_npm_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_npm_packages_rest_required_fields(request_type=artifact.ListNpmPackagesRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_npm_packages._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_npm_packages._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.ListNpmPackagesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListNpmPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_npm_packages(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_npm_packages_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_npm_packages._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_npm_packages_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListNpmPackagesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.ListNpmPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_npm_packages(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/npmPackages" % client.transport._host, args[1]) - - -def test_list_npm_packages_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_npm_packages( - artifact.ListNpmPackagesRequest(), - parent='parent_value', - ) - - -def test_list_npm_packages_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(artifact.ListNpmPackagesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_npm_packages(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.NpmPackage) - for i in results) - - pages = list(client.list_npm_packages(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_npm_package_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_npm_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_npm_package] = mock_rpc - - request = {} - client.get_npm_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_npm_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_npm_package_rest_required_fields(request_type=artifact.GetNpmPackageRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_npm_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_npm_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.NpmPackage() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.NpmPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_npm_package(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_npm_package_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_npm_package._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_npm_package_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.NpmPackage() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.NpmPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_npm_package(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/npmPackages/*}" % client.transport._host, args[1]) - - -def test_get_npm_package_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_npm_package( - artifact.GetNpmPackageRequest(), - name='name_value', - ) - - -def test_list_python_packages_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_python_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_python_packages] = mock_rpc - - request = {} - client.list_python_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_python_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_python_packages_rest_required_fields(request_type=artifact.ListPythonPackagesRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_python_packages._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_python_packages._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.ListPythonPackagesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListPythonPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_python_packages(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_python_packages_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_python_packages._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_python_packages_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListPythonPackagesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.ListPythonPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_python_packages(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/pythonPackages" % client.transport._host, args[1]) - - -def test_list_python_packages_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_python_packages( - artifact.ListPythonPackagesRequest(), - parent='parent_value', - ) - - -def test_list_python_packages_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(artifact.ListPythonPackagesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_python_packages(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.PythonPackage) - for i in results) - - pages = list(client.list_python_packages(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_python_package_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_python_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_python_package] = mock_rpc - - request = {} - client.get_python_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_python_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_python_package_rest_required_fields(request_type=artifact.GetPythonPackageRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_python_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_python_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.PythonPackage() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.PythonPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_python_package(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_python_package_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_python_package._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_python_package_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.PythonPackage() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.PythonPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_python_package(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/pythonPackages/*}" % client.transport._host, args[1]) - - -def test_get_python_package_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_python_package( - artifact.GetPythonPackageRequest(), - name='name_value', - ) - - -def test_import_apt_artifacts_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.import_apt_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.import_apt_artifacts] = mock_rpc - - request = {} - client.import_apt_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_apt_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_import_yum_artifacts_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.import_yum_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.import_yum_artifacts] = mock_rpc - - request = {} - client.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_yum_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_repositories_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_repositories in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_repositories] = mock_rpc - - request = {} - client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_repositories(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_repositories_rest_required_fields(request_type=repository.ListRepositoriesRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_repositories._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_repositories._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_repositories(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_repositories_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_repositories._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_repositories_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_repositories(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/repositories" % client.transport._host, args[1]) - - -def test_list_repositories_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_repositories_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(repository.ListRepositoriesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_repositories(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, repository.Repository) - for i in results) - - pages = list(client.list_repositories(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_repository] = mock_rpc - - request = {} - client.get_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_repository_rest_required_fields(request_type=repository.GetRepositoryRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = repository.Repository() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_repository(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_repository_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_repository_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = repository.Repository() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*}" % client.transport._host, args[1]) - - -def test_get_repository_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_create_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_repository] = mock_rpc - - request = {} - client.create_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_repository_rest_required_fields(request_type=gda_repository.CreateRepositoryRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["repository_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "repositoryId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "repositoryId" in jsonified_request - assert jsonified_request["repositoryId"] == request_init["repository_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["repositoryId"] = 'repository_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_repository._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("repository_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "repositoryId" in jsonified_request - assert jsonified_request["repositoryId"] == 'repository_id_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_repository(request) - - expected_params = [ - ( - "repositoryId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_repository_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(("repositoryId", )) & set(("parent", "repositoryId", "repository", ))) - - -def test_create_repository_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - repository=gda_repository.Repository(maven_config=gda_repository.Repository.MavenRepositoryConfig(allow_snapshot_overwrites=True)), - repository_id='repository_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/repositories" % client.transport._host, args[1]) - - -def test_create_repository_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_update_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_repository] = mock_rpc - - request = {} - client.update_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_repository_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_repository.Repository() - - # get arguments that satisfy an http rule for this method - sample_request = {'repository': {'name': 'projects/sample1/locations/sample2/repositories/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - repository=gda_repository.Repository(maven_config=gda_repository.Repository.MavenRepositoryConfig(allow_snapshot_overwrites=True)), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{repository.name=projects/*/locations/*/repositories/*}" % client.transport._host, args[1]) - - -def test_update_repository_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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']), - ) - - -def test_delete_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_repository] = mock_rpc - - request = {} - client.delete_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_repository_rest_required_fields(request_type=repository.DeleteRepositoryRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_repository(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_repository_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_repository_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*}" % client.transport._host, args[1]) - - -def test_delete_repository_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_packages_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_packages] = mock_rpc - - request = {} - client.list_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_packages_rest_required_fields(request_type=package.ListPackagesRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_packages._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_packages._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = package.ListPackagesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = package.ListPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_packages(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_packages_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_packages._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_packages_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = package.ListPackagesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = package.ListPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_packages(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/packages" % client.transport._host, args[1]) - - -def test_list_packages_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_packages_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(package.ListPackagesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_packages(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, package.Package) - for i in results) - - pages = list(client.list_packages(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_package_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_package] = mock_rpc - - request = {} - client.get_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_package_rest_required_fields(request_type=package.GetPackageRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = package.Package() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_package(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_package_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_package._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_package_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = package.Package() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_package(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/packages/*}" % client.transport._host, args[1]) - - -def test_get_package_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_delete_package_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_package] = mock_rpc - - request = {} - client.delete_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_package_rest_required_fields(request_type=package.DeletePackageRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_package(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_package_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_package._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_package_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_package(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/packages/*}" % client.transport._host, args[1]) - - -def test_delete_package_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_versions_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_versions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_versions] = mock_rpc - - request = {} - client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_versions_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = version.ListVersionsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = version.ListVersionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_versions(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/versions" % client.transport._host, args[1]) - - -def test_list_versions_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_versions_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(version.ListVersionsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - pager = client.list_versions(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, version.Version) - for i in results) - - pages = list(client.list_versions(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_version_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_version] = mock_rpc - - request = {} - client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_version_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = version.Version() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = version.Version.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_version(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}" % client.transport._host, args[1]) - - -def test_get_version_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_delete_version_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_version] = mock_rpc - - request = {} - client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_version_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_version(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}" % client.transport._host, args[1]) - - -def test_delete_version_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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(), - name='name_value', - ) - - -def test_batch_delete_versions_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.batch_delete_versions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.batch_delete_versions] = mock_rpc - - request = {} - client.batch_delete_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.batch_delete_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_batch_delete_versions_rest_required_fields(request_type=version.BatchDeleteVersionsRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["names"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).batch_delete_versions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["names"] = 'names_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).batch_delete_versions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "names" in jsonified_request - assert jsonified_request["names"] == 'names_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.batch_delete_versions(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_batch_delete_versions_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.batch_delete_versions._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("names", ))) - - -def test_batch_delete_versions_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - names=['names_value'], - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.batch_delete_versions(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/versions:batchDelete" % client.transport._host, args[1]) - - -def test_batch_delete_versions_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.batch_delete_versions( - version.BatchDeleteVersionsRequest(), - parent='parent_value', - names=['names_value'], - ) - - -def test_update_version_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_version] = mock_rpc - - request = {} - client.update_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_version_rest_required_fields(request_type=gda_version.UpdateVersionRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_version._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_version._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = gda_version.Version() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_version.Version.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_version(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_version_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_version._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("version", ))) - - -def test_update_version_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_version.Version() - - # get arguments that satisfy an http rule for this method - sample_request = {'version': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'}} - - # get truthy value for each flattened field - mock_args = dict( - version=gda_version.Version(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_version.Version.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_version(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{version.name=projects/*/locations/*/repositories/*/packages/*/versions/*}" % client.transport._host, args[1]) - - -def test_update_version_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_version( - gda_version.UpdateVersionRequest(), - version=gda_version.Version(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_list_files_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_files in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_files] = mock_rpc - - request = {} - client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_files(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_files_rest_required_fields(request_type=file.ListFilesRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_files._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_files._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = file.ListFilesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = file.ListFilesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_files(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_files_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_files._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_files_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = file.ListFilesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = file.ListFilesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_files(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/files" % client.transport._host, args[1]) - - -def test_list_files_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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(), - parent='parent_value', - ) - - -def test_list_files_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(file.ListFilesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_files(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, file.File) - for i in results) - - pages = list(client.list_files(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_file_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_file in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_file] = mock_rpc - - request = {} - client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_file_rest_required_fields(request_type=file.GetFileRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_file._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_file._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = file.File() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = file.File.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_file(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_file_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_file._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_file_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = file.File() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = file.File.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_file(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/files/**}" % client.transport._host, args[1]) - - -def test_get_file_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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(), - name='name_value', - ) - - -def test_delete_file_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_file in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_file] = mock_rpc - - request = {} - client.delete_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_file_rest_required_fields(request_type=file.DeleteFileRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_file._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_file._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_file(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_file_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_file._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_file_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_file(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/files/*}" % client.transport._host, args[1]) - - -def test_delete_file_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_file( - file.DeleteFileRequest(), - name='name_value', - ) - - -def test_update_file_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_file in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_file] = mock_rpc - - request = {} - client.update_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_file_rest_required_fields(request_type=gda_file.UpdateFileRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_file._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_file._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = gda_file.File() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_file.File.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_file(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_file_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_file._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("file", "updateMask", ))) - - -def test_update_file_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_file.File() - - # get arguments that satisfy an http rule for this method - sample_request = {'file': {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - file=gda_file.File(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_file.File.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_file(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{file.name=projects/*/locations/*/repositories/*/files/*}" % client.transport._host, args[1]) - - -def test_update_file_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_file( - gda_file.UpdateFileRequest(), - file=gda_file.File(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_list_tags_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_tags in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_tags] = mock_rpc - - request = {} - client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_tags(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_tags_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = tag.ListTagsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = tag.ListTagsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_tags(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/tags" % client.transport._host, args[1]) - - -def test_list_tags_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_tags_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(tag.ListTagsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - pager = client.list_tags(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, tag.Tag) - for i in results) - - pages = list(client.list_tags(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_tag] = mock_rpc - - request = {} - client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = tag.Tag() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_tag(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}" % client.transport._host, args[1]) - - -def test_get_tag_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_create_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_tag] = mock_rpc - - request = {} - client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - tag=gda_tag.Tag(name='name_value'), - tag_id='tag_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_tag(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/tags" % client.transport._host, args[1]) - - -def test_create_tag_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_update_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_tag] = mock_rpc - - request = {} - client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag() - - # get arguments that satisfy an http rule for this method - sample_request = {'tag': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'}} - - # get truthy value for each flattened field - mock_args = dict( - tag=gda_tag.Tag(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_tag(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{tag.name=projects/*/locations/*/repositories/*/packages/*/tags/*}" % client.transport._host, args[1]) - - -def test_update_tag_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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']), - ) - - -def test_delete_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_tag] = mock_rpc - - request = {} - client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.delete_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_tag(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}" % client.transport._host, args[1]) - - -def test_delete_tag_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_create_rule_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_rule in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_rule] = mock_rpc - - request = {} - client.create_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_rule_rest_required_fields(request_type=gda_rule.CreateRuleRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_rule._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("rule_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = gda_rule.Rule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_rule.Rule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_rule(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_rule_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(("ruleId", )) & set(("parent", ))) - - -def test_create_rule_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_rule.Rule() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - rule=gda_rule.Rule(name='name_value'), - rule_id='rule_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_rule.Rule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_rule(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/rules" % client.transport._host, args[1]) - - -def test_create_rule_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_rule( - gda_rule.CreateRuleRequest(), - parent='parent_value', - rule=gda_rule.Rule(name='name_value'), - rule_id='rule_id_value', - ) - - -def test_list_rules_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_rules in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_rules] = mock_rpc - - request = {} - client.list_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_rules(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_rules_rest_required_fields(request_type=rule.ListRulesRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_rules._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_rules._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = rule.ListRulesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = rule.ListRulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_rules(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_rules_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_rules._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_rules_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = rule.ListRulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = rule.ListRulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_rules(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/rules" % client.transport._host, args[1]) - - -def test_list_rules_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_rules( - rule.ListRulesRequest(), - parent='parent_value', - ) - - -def test_list_rules_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - rule.Rule(), - ], - next_page_token='abc', - ), - rule.ListRulesResponse( - rules=[], - next_page_token='def', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - ], - next_page_token='ghi', - ), - rule.ListRulesResponse( - rules=[ - rule.Rule(), - rule.Rule(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(rule.ListRulesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_rules(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, rule.Rule) - for i in results) - - pages = list(client.list_rules(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_rule_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_rule in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_rule] = mock_rpc - - request = {} - client.get_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_rule_rest_required_fields(request_type=rule.GetRuleRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = rule.Rule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = rule.Rule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_rule(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_rule_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_rule_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = rule.Rule() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = rule.Rule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_rule(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/rules/*}" % client.transport._host, args[1]) - - -def test_get_rule_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_rule( - rule.GetRuleRequest(), - name='name_value', - ) - - -def test_update_rule_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_rule in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_rule] = mock_rpc - - request = {} - client.update_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_rule_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_rule.Rule() - - # get arguments that satisfy an http rule for this method - sample_request = {'rule': {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - rule=gda_rule.Rule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_rule.Rule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_rule(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{rule.name=projects/*/locations/*/repositories/*/rules/*}" % client.transport._host, args[1]) - - -def test_update_rule_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_rule( - gda_rule.UpdateRuleRequest(), - rule=gda_rule.Rule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_rule_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_rule in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_rule] = mock_rpc - - request = {} - client.delete_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.delete_rule(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_rule_rest_required_fields(request_type=rule.DeleteRuleRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_rule(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_rule_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_rule_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_rule(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/rules/*}" % client.transport._host, args[1]) - - -def test_delete_rule_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_rule( - rule.DeleteRuleRequest(), - name='name_value', - ) - - -def test_set_iam_policy_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.set_iam_policy in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.set_iam_policy] = mock_rpc - - request = {} - client.set_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.set_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_set_iam_policy_rest_required_fields(request_type=iam_policy_pb2.SetIamPolicyRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["resource"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).set_iam_policy._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = 'resource_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).set_iam_policy._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == 'resource_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.set_iam_policy(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_set_iam_policy_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.set_iam_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("resource", "policy", ))) - - -def test_get_iam_policy_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_iam_policy in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_iam_policy] = mock_rpc - - request = {} - client.get_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_iam_policy_rest_required_fields(request_type=iam_policy_pb2.GetIamPolicyRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["resource"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_iam_policy._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = 'resource_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_iam_policy._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("options", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == 'resource_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_iam_policy(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_iam_policy_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_iam_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(("options", )) & set(("resource", ))) - - -def test_test_iam_permissions_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.test_iam_permissions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.test_iam_permissions] = mock_rpc - - request = {} - client.test_iam_permissions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.test_iam_permissions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_test_iam_permissions_rest_required_fields(request_type=iam_policy_pb2.TestIamPermissionsRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["resource"] = "" - request_init["permissions"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).test_iam_permissions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = 'resource_value' - jsonified_request["permissions"] = 'permissions_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).test_iam_permissions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == 'resource_value' - assert "permissions" in jsonified_request - assert jsonified_request["permissions"] == 'permissions_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.test_iam_permissions(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_test_iam_permissions_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.test_iam_permissions._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("resource", "permissions", ))) - - -def test_get_project_settings_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_project_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_project_settings] = mock_rpc - - request = {} - client.get_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_project_settings_rest_required_fields(request_type=settings.GetProjectSettingsRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_project_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_project_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_project_settings(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_project_settings_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_project_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_project_settings_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/projectSettings'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_project_settings(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/projectSettings}" % client.transport._host, args[1]) - - -def test_get_project_settings_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_update_project_settings_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_project_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_project_settings] = mock_rpc - - request = {} - client.update_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_project_settings_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() - - # get arguments that satisfy an http rule for this method - sample_request = {'project_settings': {'name': 'projects/sample1/projectSettings'}} - - # get truthy value for each flattened field - mock_args = dict( - project_settings=settings.ProjectSettings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_project_settings(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{project_settings.name=projects/*/projectSettings}" % client.transport._host, args[1]) - - -def test_update_project_settings_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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']), - ) - - -def test_get_vpcsc_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vpcsc_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vpcsc_config] = mock_rpc - - request = {} - client.get_vpcsc_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vpcsc_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_vpcsc_config_rest_required_fields(request_type=vpcsc_config.GetVPCSCConfigRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vpcsc_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vpcsc_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = vpcsc_config.VPCSCConfig() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = vpcsc_config.VPCSCConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_vpcsc_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_vpcsc_config_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_vpcsc_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_vpcsc_config_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = vpcsc_config.VPCSCConfig() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/vpcscConfig'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = vpcsc_config.VPCSCConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_vpcsc_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/vpcscConfig}" % client.transport._host, args[1]) - - -def test_get_vpcsc_config_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vpcsc_config( - vpcsc_config.GetVPCSCConfigRequest(), - name='name_value', - ) - - -def test_update_vpcsc_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_vpcsc_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_vpcsc_config] = mock_rpc - - request = {} - client.update_vpcsc_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_vpcsc_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_vpcsc_config_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_vpcsc_config.VPCSCConfig() - - # get arguments that satisfy an http rule for this method - sample_request = {'vpcsc_config': {'name': 'projects/sample1/locations/sample2/vpcscConfig'}} - - # get truthy value for each flattened field - mock_args = dict( - vpcsc_config=gda_vpcsc_config.VPCSCConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_vpcsc_config.VPCSCConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_vpcsc_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{vpcsc_config.name=projects/*/locations/*/vpcscConfig}" % client.transport._host, args[1]) - - -def test_update_vpcsc_config_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - 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']), - ) - - -def test_update_package_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_package] = mock_rpc - - request = {} - client.update_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_package_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_package.Package() - - # get arguments that satisfy an http rule for this method - sample_request = {'package': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'}} - - # get truthy value for each flattened field - mock_args = dict( - package=gda_package.Package(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_package(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{package.name=projects/*/locations/*/repositories/*/packages/*}" % client.transport._host, args[1]) - - -def test_update_package_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_package( - gda_package.UpdatePackageRequest(), - package=gda_package.Package(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_list_attachments_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_attachments in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_attachments] = mock_rpc - - request = {} - client.list_attachments(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_attachments(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_attachments_rest_required_fields(request_type=attachment.ListAttachmentsRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_attachments._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_attachments._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = attachment.ListAttachmentsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = attachment.ListAttachmentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_attachments(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_attachments_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_attachments._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_attachments_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = attachment.ListAttachmentsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = attachment.ListAttachmentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_attachments(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/attachments" % client.transport._host, args[1]) - - -def test_list_attachments_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_attachments( - attachment.ListAttachmentsRequest(), - parent='parent_value', - ) - - -def test_list_attachments_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - attachment.Attachment(), - ], - next_page_token='abc', - ), - attachment.ListAttachmentsResponse( - attachments=[], - next_page_token='def', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - ], - next_page_token='ghi', - ), - attachment.ListAttachmentsResponse( - attachments=[ - attachment.Attachment(), - attachment.Attachment(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(attachment.ListAttachmentsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_attachments(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, attachment.Attachment) - for i in results) - - pages = list(client.list_attachments(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_attachment_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_attachment in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_attachment] = mock_rpc - - request = {} - client.get_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_attachment_rest_required_fields(request_type=attachment.GetAttachmentRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_attachment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_attachment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = attachment.Attachment() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = attachment.Attachment.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_attachment(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_attachment_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_attachment._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_attachment_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = attachment.Attachment() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/attachments/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = attachment.Attachment.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_attachment(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/attachments/*}" % client.transport._host, args[1]) - - -def test_get_attachment_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_attachment( - attachment.GetAttachmentRequest(), - name='name_value', - ) - - -def test_create_attachment_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_attachment in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_attachment] = mock_rpc - - request = {} - client.create_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_attachment_rest_required_fields(request_type=gda_attachment.CreateAttachmentRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["attachment_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "attachmentId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_attachment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "attachmentId" in jsonified_request - assert jsonified_request["attachmentId"] == request_init["attachment_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["attachmentId"] = 'attachment_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_attachment._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("attachment_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "attachmentId" in jsonified_request - assert jsonified_request["attachmentId"] == 'attachment_id_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_attachment(request) - - expected_params = [ - ( - "attachmentId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_attachment_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_attachment._get_unset_required_fields({}) - assert set(unset_fields) == (set(("attachmentId", )) & set(("parent", "attachmentId", "attachment", ))) - - -def test_create_attachment_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - attachment=gda_attachment.Attachment(name='name_value'), - attachment_id='attachment_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_attachment(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/repositories/*}/attachments" % client.transport._host, args[1]) - - -def test_create_attachment_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_attachment( - gda_attachment.CreateAttachmentRequest(), - parent='parent_value', - attachment=gda_attachment.Attachment(name='name_value'), - attachment_id='attachment_id_value', - ) - - -def test_delete_attachment_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_attachment in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_attachment] = mock_rpc - - request = {} - client.delete_attachment(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_attachment(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_attachment_rest_required_fields(request_type=attachment.DeleteAttachmentRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_attachment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_attachment._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_attachment(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_attachment_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_attachment._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_attachment_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/attachments/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_attachment(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/repositories/*/attachments/*}" % client.transport._host, args[1]) - - -def test_delete_attachment_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_attachment( - attachment.DeleteAttachmentRequest(), - name='name_value', - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = ArtifactRegistryClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.ArtifactRegistryGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryGrpcAsyncIOTransport, - transports.ArtifactRegistryRestTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -def test_transport_kind_grpc(): - transport = ArtifactRegistryClient.get_transport_class("grpc")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" - - -def test_initialize_client_w_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc" - ) - assert client is not None - - -# 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_docker_images_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__') as call: - call.return_value = artifact.ListDockerImagesResponse() - client.list_docker_images(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListDockerImagesRequest() - - assert args[0] == request_msg - - -# 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_get_docker_image_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_docker_image), - '__call__') as call: - call.return_value = artifact.DockerImage() - client.get_docker_image(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetDockerImageRequest() - - assert args[0] == request_msg - - -# 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_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_maven_artifacts), - '__call__') as call: - call.return_value = artifact.ListMavenArtifactsResponse() - client.list_maven_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListMavenArtifactsRequest() - - assert args[0] == request_msg - - -# 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_get_maven_artifact_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_maven_artifact), - '__call__') as call: - call.return_value = artifact.MavenArtifact() - client.get_maven_artifact(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetMavenArtifactRequest() - - assert args[0] == request_msg - - -# 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_npm_packages_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_npm_packages), - '__call__') as call: - call.return_value = artifact.ListNpmPackagesResponse() - client.list_npm_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListNpmPackagesRequest() - - assert args[0] == request_msg - - -# 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_get_npm_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_npm_package), - '__call__') as call: - call.return_value = artifact.NpmPackage() - client.get_npm_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetNpmPackageRequest() - - assert args[0] == request_msg - - -# 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_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), - '__call__') as call: - call.return_value = artifact.ListPythonPackagesResponse() - client.list_python_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListPythonPackagesRequest() - - assert args[0] == request_msg - - -# 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_get_python_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_python_package), - '__call__') as call: - call.return_value = artifact.PythonPackage() - client.get_python_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetPythonPackageRequest() - - assert args[0] == request_msg - - -# 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_import_apt_artifacts_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = apt_artifact.ImportAptArtifactsRequest() - - assert args[0] == request_msg - - -# 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_import_yum_artifacts_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = yum_artifact.ImportYumArtifactsRequest() - - assert args[0] == request_msg - - -# 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_repositories_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.ListRepositoriesRequest() - - assert args[0] == request_msg - - -# 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_get_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.GetRepositoryRequest() - - assert args[0] == request_msg - - -# 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_create_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.CreateRepositoryRequest() - - assert args[0] == request_msg - - -# 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_update_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.UpdateRepositoryRequest() - - assert args[0] == request_msg - - -# 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_delete_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.DeleteRepositoryRequest() - - assert args[0] == request_msg - - -# 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_packages_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.ListPackagesRequest() - - assert args[0] == request_msg - - -# 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_get_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.GetPackageRequest() - - assert args[0] == request_msg - - -# 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_delete_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.DeletePackageRequest() - - assert args[0] == request_msg - - -# 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_versions_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.ListVersionsRequest() - - assert args[0] == request_msg - - -# 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_get_version_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.GetVersionRequest() - - assert args[0] == request_msg - - -# 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_delete_version_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.DeleteVersionRequest() - - assert args[0] == request_msg - - -# 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_batch_delete_versions_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.batch_delete_versions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.BatchDeleteVersionsRequest() - - assert args[0] == request_msg - - -# 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_update_version_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_version), - '__call__') as call: - call.return_value = gda_version.Version() - client.update_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_version.UpdateVersionRequest() - - assert args[0] == request_msg - - -# 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_files_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.ListFilesRequest() - - assert args[0] == request_msg - - -# 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_get_file_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.GetFileRequest() - - assert args[0] == request_msg - - -# 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_delete_file_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_file), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.DeleteFileRequest() - - assert args[0] == request_msg - - -# 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_update_file_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_file), - '__call__') as call: - call.return_value = gda_file.File() - client.update_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_file.UpdateFileRequest() - - assert args[0] == request_msg - - -# 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_tags_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.ListTagsRequest() - - assert args[0] == request_msg - - -# 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_get_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.GetTagRequest() - - assert args[0] == request_msg - - -# 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_create_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.CreateTagRequest() - - assert args[0] == request_msg - - -# 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_update_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.UpdateTagRequest() - - assert args[0] == request_msg - - -# 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_delete_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - call.return_value = None - client.delete_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.DeleteTagRequest() - - assert args[0] == request_msg - - -# 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_create_rule_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_rule), - '__call__') as call: - call.return_value = gda_rule.Rule() - client.create_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_rule.CreateRuleRequest() - - assert args[0] == request_msg - - -# 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_rules_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__') as call: - call.return_value = rule.ListRulesResponse() - client.list_rules(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.ListRulesRequest() - - assert args[0] == request_msg - - -# 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_get_rule_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_rule), - '__call__') as call: - call.return_value = rule.Rule() - client.get_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.GetRuleRequest() - - assert args[0] == request_msg - - -# 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_update_rule_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_rule), - '__call__') as call: - call.return_value = gda_rule.Rule() - client.update_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_rule.UpdateRuleRequest() - - assert args[0] == request_msg - - -# 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_delete_rule_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_rule), - '__call__') as call: - call.return_value = None - client.delete_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.DeleteRuleRequest() - - assert args[0] == request_msg - - -# 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_set_iam_policy_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() - - assert args[0] == request_msg - - -# 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_get_iam_policy_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() - - assert args[0] == request_msg - - -# 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_test_iam_permissions_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() - - assert args[0] == request_msg - - -# 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_get_project_settings_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.GetProjectSettingsRequest() - - assert args[0] == request_msg - - -# 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_update_project_settings_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_project_settings), - '__call__') as call: - call.return_value = settings.ProjectSettings() - client.update_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.UpdateProjectSettingsRequest() - - assert args[0] == request_msg - - -# 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_get_vpcsc_config_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = vpcsc_config.GetVPCSCConfigRequest() - - assert args[0] == request_msg - - -# 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_update_vpcsc_config_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), - '__call__') as call: - call.return_value = gda_vpcsc_config.VPCSCConfig() - client.update_vpcsc_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_vpcsc_config.UpdateVPCSCConfigRequest() - - assert args[0] == request_msg - - -# 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_update_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_package), - '__call__') as call: - call.return_value = gda_package.Package() - client.update_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_package.UpdatePackageRequest() - - assert args[0] == request_msg - - -# 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_attachments_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__') as call: - call.return_value = attachment.ListAttachmentsResponse() - client.list_attachments(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.ListAttachmentsRequest() - - assert args[0] == request_msg - - -# 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_get_attachment_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_attachment), - '__call__') as call: - call.return_value = attachment.Attachment() - client.get_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.GetAttachmentRequest() - - assert args[0] == request_msg - - -# 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_create_attachment_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_attachment), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_attachment.CreateAttachmentRequest() - - assert args[0] == request_msg - - -# 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_delete_attachment_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_attachment), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.DeleteAttachmentRequest() - - assert args[0] == request_msg - - -def test_transport_kind_grpc_asyncio(): - transport = ArtifactRegistryAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" - - -def test_initialize_client_w_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_docker_images_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListDockerImagesResponse( - next_page_token='next_page_token_value', - )) - await client.list_docker_images(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListDockerImagesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_docker_image_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_docker_image), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.DockerImage( - name='name_value', - uri='uri_value', - tags=['tags_value'], - image_size_bytes=1699, - media_type='media_type_value', - )) - await client.get_docker_image(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetDockerImageRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_maven_artifacts_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_maven_artifacts), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListMavenArtifactsResponse( - next_page_token='next_page_token_value', - )) - await client.list_maven_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListMavenArtifactsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_maven_artifact_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(artifact.MavenArtifact( - name='name_value', - pom_uri='pom_uri_value', - group_id='group_id_value', - artifact_id='artifact_id_value', - version='version_value', - )) - await client.get_maven_artifact(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetMavenArtifactRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_npm_packages_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - 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(artifact.ListNpmPackagesResponse( - next_page_token='next_page_token_value', - )) - await client.list_npm_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListNpmPackagesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_npm_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - 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(artifact.NpmPackage( - name='name_value', - package_name='package_name_value', - version='version_value', - tags=['tags_value'], - )) - await client.get_npm_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetNpmPackageRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_python_packages_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.ListPythonPackagesResponse( - next_page_token='next_page_token_value', - )) - await client.list_python_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListPythonPackagesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_python_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - )) - await client.get_python_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetPythonPackageRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_import_apt_artifacts_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - 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( - operations_pb2.Operation(name='operations/spam') - ) - await client.import_apt_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = apt_artifact.ImportAptArtifactsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_import_yum_artifacts_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.import_yum_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') - ) - await client.import_yum_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = yum_artifact.ImportYumArtifactsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_repositories_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(repository.ListRepositoriesResponse( - next_page_token='next_page_token_value', - )) - await client.list_repositories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.ListRepositoriesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - mode=repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - disallow_unspecified_mode=True, - satisfies_pzi=True, - )) - await client.get_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.GetRepositoryRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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') - ) - await client.create_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.CreateRepositoryRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - mode=gda_repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - disallow_unspecified_mode=True, - satisfies_pzi=True, - )) - await client.update_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.UpdateRepositoryRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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') - ) - await client.delete_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.DeleteRepositoryRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_packages_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - )) - await client.list_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.ListPackagesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - )) - await client.get_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.GetPackageRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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') - ) - await client.delete_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.DeletePackageRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_versions_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.ListVersionsResponse( - next_page_token='next_page_token_value', - )) - await client.list_versions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.ListVersionsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_version_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.Version( - name='name_value', - description='description_value', - )) - await client.get_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.GetVersionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_version_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.delete_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.DeleteVersionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_batch_delete_versions_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.batch_delete_versions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.BatchDeleteVersionsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_version_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_version.Version( - name='name_value', - description='description_value', - )) - await client.update_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_version.UpdateVersionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_files_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.ListFilesResponse( - next_page_token='next_page_token_value', - )) - await client.list_files(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.ListFilesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_file_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - )) - await client.get_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.GetFileRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_file_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_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') - ) - await client.delete_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.DeleteFileRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_file_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - )) - await client.update_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_file.UpdateFileRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_tags_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(tag.ListTagsResponse( - next_page_token='next_page_token_value', - )) - await client.list_tags(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.ListTagsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag( - name='name_value', - version='version_value', - )) - await client.get_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.GetTagRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag( - name='name_value', - version='version_value', - )) - await client.create_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.CreateTagRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag( - name='name_value', - version='version_value', - )) - await client.update_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.UpdateTagRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.DeleteTagRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_rule_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule( - name='name_value', - action=gda_rule.Rule.Action.ALLOW, - operation=gda_rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - )) - await client.create_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_rule.CreateRuleRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_rules_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(rule.ListRulesResponse( - next_page_token='next_page_token_value', - )) - await client.list_rules(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.ListRulesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_rule_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(rule.Rule( - name='name_value', - action=rule.Rule.Action.ALLOW, - operation=rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - )) - await client.get_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.GetRuleRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_rule_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule( - name='name_value', - action=gda_rule.Rule.Action.ALLOW, - operation=gda_rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - )) - await client.update_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_rule.UpdateRuleRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_rule_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_rule), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.DeleteRuleRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_set_iam_policy_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy( - version=774, - etag=b'etag_blob', - )) - await client.set_iam_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_iam_policy_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy( - version=774, - etag=b'etag_blob', - )) - await client.get_iam_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_test_iam_permissions_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(iam_policy_pb2.TestIamPermissionsResponse( - permissions=['permissions_value'], - )) - await client.test_iam_permissions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_project_settings_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - pull_percent=1293, - )) - await client.get_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.GetProjectSettingsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_project_settings_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - pull_percent=1293, - )) - await client.update_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.UpdateProjectSettingsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vpcsc_config_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - 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(vpcsc_config.VPCSCConfig( - name='name_value', - vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - )) - await client.get_vpcsc_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = vpcsc_config.GetVPCSCConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_vpcsc_config_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_vpcsc_config.VPCSCConfig( - name='name_value', - vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - )) - await client.update_vpcsc_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_vpcsc_config.UpdateVPCSCConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_package), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_package.Package( - name='name_value', - display_name='display_name_value', - )) - await client.update_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_package.UpdatePackageRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_attachments_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(attachment.ListAttachmentsResponse( - next_page_token='next_page_token_value', - )) - await client.list_attachments(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.ListAttachmentsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_attachment_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(attachment.Attachment( - name='name_value', - target='target_value', - type_='type__value', - attachment_namespace='attachment_namespace_value', - files=['files_value'], - oci_version_name='oci_version_name_value', - )) - await client.get_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.GetAttachmentRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_attachment_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.create_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_attachment.CreateAttachmentRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_attachment_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_attachment), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.delete_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.DeleteAttachmentRequest() - - assert args[0] == request_msg - - -def test_transport_kind_rest(): - transport = ArtifactRegistryClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" - - -def test_list_docker_images_rest_bad_request(request_type=artifact.ListDockerImagesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_docker_images(request) - - -@pytest.mark.parametrize("request_type", [ - artifact.ListDockerImagesRequest, - dict, -]) -def test_list_docker_images_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListDockerImagesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListDockerImagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_docker_images(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDockerImagesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_docker_images_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_docker_images") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_docker_images") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = artifact.ListDockerImagesRequest.pb(artifact.ListDockerImagesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = artifact.ListDockerImagesResponse.to_json(artifact.ListDockerImagesResponse()) - req.return_value.content = return_value - - request = artifact.ListDockerImagesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = artifact.ListDockerImagesResponse() - - client.list_docker_images(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_docker_image_rest_bad_request(request_type=artifact.GetDockerImageRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_docker_image(request) - - -@pytest.mark.parametrize("request_type", [ - artifact.GetDockerImageRequest, - dict, -]) -def test_get_docker_image_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.DockerImage( - name='name_value', - uri='uri_value', - tags=['tags_value'], - image_size_bytes=1699, - media_type='media_type_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.DockerImage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_docker_image(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, artifact.DockerImage) - assert response.name == 'name_value' - assert response.uri == 'uri_value' - assert response.tags == ['tags_value'] - assert response.image_size_bytes == 1699 - assert response.media_type == 'media_type_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_docker_image_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_docker_image") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_docker_image") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = artifact.GetDockerImageRequest.pb(artifact.GetDockerImageRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = artifact.DockerImage.to_json(artifact.DockerImage()) - req.return_value.content = return_value - - request = artifact.GetDockerImageRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = artifact.DockerImage() - - client.get_docker_image(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_maven_artifacts_rest_bad_request(request_type=artifact.ListMavenArtifactsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_maven_artifacts(request) - - -@pytest.mark.parametrize("request_type", [ - artifact.ListMavenArtifactsRequest, - dict, -]) -def test_list_maven_artifacts_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListMavenArtifactsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListMavenArtifactsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_maven_artifacts(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMavenArtifactsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_maven_artifacts_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_maven_artifacts") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_maven_artifacts") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = artifact.ListMavenArtifactsRequest.pb(artifact.ListMavenArtifactsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = artifact.ListMavenArtifactsResponse.to_json(artifact.ListMavenArtifactsResponse()) - req.return_value.content = return_value - - request = artifact.ListMavenArtifactsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = artifact.ListMavenArtifactsResponse() - - client.list_maven_artifacts(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_maven_artifact_rest_bad_request(request_type=artifact.GetMavenArtifactRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_maven_artifact(request) - - -@pytest.mark.parametrize("request_type", [ - artifact.GetMavenArtifactRequest, - dict, -]) -def test_get_maven_artifact_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - 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', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.MavenArtifact.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_maven_artifact(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_maven_artifact_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_maven_artifact") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_maven_artifact") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = artifact.GetMavenArtifactRequest.pb(artifact.GetMavenArtifactRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = artifact.MavenArtifact.to_json(artifact.MavenArtifact()) - req.return_value.content = return_value - - request = artifact.GetMavenArtifactRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = artifact.MavenArtifact() - - client.get_maven_artifact(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_npm_packages_rest_bad_request(request_type=artifact.ListNpmPackagesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_npm_packages(request) - - -@pytest.mark.parametrize("request_type", [ - artifact.ListNpmPackagesRequest, - dict, -]) -def test_list_npm_packages_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListNpmPackagesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListNpmPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_npm_packages(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListNpmPackagesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_npm_packages_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_npm_packages") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_npm_packages") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = artifact.ListNpmPackagesRequest.pb(artifact.ListNpmPackagesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = artifact.ListNpmPackagesResponse.to_json(artifact.ListNpmPackagesResponse()) - req.return_value.content = return_value - - request = artifact.ListNpmPackagesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = artifact.ListNpmPackagesResponse() - - client.list_npm_packages(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_npm_package_rest_bad_request(request_type=artifact.GetNpmPackageRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_npm_package(request) - - -@pytest.mark.parametrize("request_type", [ - artifact.GetNpmPackageRequest, - dict, -]) -def test_get_npm_package_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.NpmPackage( - name='name_value', - package_name='package_name_value', - version='version_value', - tags=['tags_value'], - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.NpmPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_npm_package(request) - - # Establish that the response is the type that we expect. - 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.parametrize("null_interceptor", [True, False]) -def test_get_npm_package_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_npm_package") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_npm_package") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = artifact.GetNpmPackageRequest.pb(artifact.GetNpmPackageRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = artifact.NpmPackage.to_json(artifact.NpmPackage()) - req.return_value.content = return_value - - request = artifact.GetNpmPackageRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = artifact.NpmPackage() - - client.get_npm_package(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_python_packages_rest_bad_request(request_type=artifact.ListPythonPackagesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_python_packages(request) - - -@pytest.mark.parametrize("request_type", [ - artifact.ListPythonPackagesRequest, - dict, -]) -def test_list_python_packages_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListPythonPackagesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListPythonPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_python_packages(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPythonPackagesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_python_packages_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_python_packages") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_python_packages") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = artifact.ListPythonPackagesRequest.pb(artifact.ListPythonPackagesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = artifact.ListPythonPackagesResponse.to_json(artifact.ListPythonPackagesResponse()) - req.return_value.content = return_value - - request = artifact.ListPythonPackagesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = artifact.ListPythonPackagesResponse() - - client.list_python_packages(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_python_package_rest_bad_request(request_type=artifact.GetPythonPackageRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_python_package(request) - - -@pytest.mark.parametrize("request_type", [ - artifact.GetPythonPackageRequest, - dict, -]) -def test_get_python_package_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = artifact.PythonPackage( - name='name_value', - uri='uri_value', - package_name='package_name_value', - version='version_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.PythonPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_python_package(request) - - # 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.parametrize("null_interceptor", [True, False]) -def test_get_python_package_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_python_package") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_python_package") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = artifact.GetPythonPackageRequest.pb(artifact.GetPythonPackageRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = artifact.PythonPackage.to_json(artifact.PythonPackage()) - req.return_value.content = return_value - - request = artifact.GetPythonPackageRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = artifact.PythonPackage() - - client.get_python_package(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_import_apt_artifacts_rest_bad_request(request_type=apt_artifact.ImportAptArtifactsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.import_apt_artifacts(request) - - -@pytest.mark.parametrize("request_type", [ - apt_artifact.ImportAptArtifactsRequest, - dict, -]) -def test_import_apt_artifacts_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.import_apt_artifacts(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_import_apt_artifacts_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_import_apt_artifacts") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_import_apt_artifacts") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = apt_artifact.ImportAptArtifactsRequest.pb(apt_artifact.ImportAptArtifactsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = apt_artifact.ImportAptArtifactsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.import_apt_artifacts(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_import_yum_artifacts_rest_bad_request(request_type=yum_artifact.ImportYumArtifactsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.import_yum_artifacts(request) - - -@pytest.mark.parametrize("request_type", [ - yum_artifact.ImportYumArtifactsRequest, - dict, -]) -def test_import_yum_artifacts_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.import_yum_artifacts(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_import_yum_artifacts_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_import_yum_artifacts") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_import_yum_artifacts") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = yum_artifact.ImportYumArtifactsRequest.pb(yum_artifact.ImportYumArtifactsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = yum_artifact.ImportYumArtifactsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.import_yum_artifacts(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_repositories_rest_bad_request(request_type=repository.ListRepositoriesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_repositories(request) - - -@pytest.mark.parametrize("request_type", [ - repository.ListRepositoriesRequest, - dict, -]) -def test_list_repositories_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_repositories(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRepositoriesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_repositories_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_repositories") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_repositories") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = repository.ListRepositoriesRequest.pb(repository.ListRepositoriesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = repository.ListRepositoriesResponse.to_json(repository.ListRepositoriesResponse()) - req.return_value.content = return_value - - request = repository.ListRepositoriesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = repository.ListRepositoriesResponse() - - client.list_repositories(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_repository_rest_bad_request(request_type=repository.GetRepositoryRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_repository(request) - - -@pytest.mark.parametrize("request_type", [ - repository.GetRepositoryRequest, - dict, -]) -def test_get_repository_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = repository.Repository( - name='name_value', - format_=repository.Repository.Format.DOCKER, - description='description_value', - kms_key_name='kms_key_name_value', - mode=repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - disallow_unspecified_mode=True, - satisfies_pzi=True, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_repository(request) - - # 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 response.mode == repository.Repository.Mode.STANDARD_REPOSITORY - assert response.size_bytes == 1089 - assert response.satisfies_pzs is True - assert response.cleanup_policy_dry_run is True - assert response.disallow_unspecified_mode is True - assert response.satisfies_pzi is True - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_repository_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_repository") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_repository") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = repository.GetRepositoryRequest.pb(repository.GetRepositoryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = repository.Repository.to_json(repository.Repository()) - req.return_value.content = return_value - - request = repository.GetRepositoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = repository.Repository() - - client.get_repository(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_repository_rest_bad_request(request_type=gda_repository.CreateRepositoryRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.create_repository(request) - - -@pytest.mark.parametrize("request_type", [ - gda_repository.CreateRepositoryRequest, - dict, -]) -def test_create_repository_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["repository"] = {'maven_config': {'allow_snapshot_overwrites': True, 'version_policy': 1}, 'docker_config': {'immutable_tags': True}, 'virtual_repository_config': {'upstream_policies': [{'id': 'id_value', 'repository': 'repository_value', 'priority': 898}]}, 'remote_repository_config': {'docker_repository': {'public_repository': 1, 'custom_repository': {'uri': 'uri_value'}}, 'maven_repository': {'public_repository': 1, 'custom_repository': {'uri': 'uri_value'}}, 'npm_repository': {'public_repository': 1, 'custom_repository': {'uri': 'uri_value'}}, 'python_repository': {'public_repository': 1, 'custom_repository': {'uri': 'uri_value'}}, 'apt_repository': {'public_repository': {'repository_base': 1, 'repository_path': 'repository_path_value'}, 'custom_repository': {'uri': 'uri_value'}}, 'yum_repository': {'public_repository': {'repository_base': 1, 'repository_path': 'repository_path_value'}, 'custom_repository': {'uri': 'uri_value'}}, 'common_repository': {'uri': 'uri_value'}, 'description': 'description_value', 'upstream_credentials': {'username_password_credentials': {'username': 'username_value', 'password_secret_version': 'password_secret_version_value'}}, 'disable_upstream_validation': True}, 'name': 'name_value', 'format_': 1, 'description': 'description_value', 'labels': {}, 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'kms_key_name': 'kms_key_name_value', 'mode': 1, 'cleanup_policies': {}, 'size_bytes': 1089, 'satisfies_pzs': True, 'cleanup_policy_dry_run': True, 'vulnerability_scanning_config': {'enablement_config': 1, 'last_enable_time': {}, 'enablement_state': 1, 'enablement_state_reason': 'enablement_state_reason_value'}, 'disallow_unspecified_mode': True, 'satisfies_pzi': True} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_repository.CreateRepositoryRequest.meta.fields["repository"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["repository"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["repository"][field])): - del request_init["repository"][field][i][subfield] - else: - del request_init["repository"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_repository(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_repository_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_create_repository") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_create_repository") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_repository.CreateRepositoryRequest.pb(gda_repository.CreateRepositoryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gda_repository.CreateRepositoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_repository(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_repository_rest_bad_request(request_type=gda_repository.UpdateRepositoryRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'repository': {'name': 'projects/sample1/locations/sample2/repositories/sample3'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_repository(request) - - -@pytest.mark.parametrize("request_type", [ - gda_repository.UpdateRepositoryRequest, - dict, -]) -def test_update_repository_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'repository': {'name': 'projects/sample1/locations/sample2/repositories/sample3'}} - request_init["repository"] = {'maven_config': {'allow_snapshot_overwrites': True, 'version_policy': 1}, 'docker_config': {'immutable_tags': True}, 'virtual_repository_config': {'upstream_policies': [{'id': 'id_value', 'repository': 'repository_value', 'priority': 898}]}, 'remote_repository_config': {'docker_repository': {'public_repository': 1, 'custom_repository': {'uri': 'uri_value'}}, 'maven_repository': {'public_repository': 1, 'custom_repository': {'uri': 'uri_value'}}, 'npm_repository': {'public_repository': 1, 'custom_repository': {'uri': 'uri_value'}}, 'python_repository': {'public_repository': 1, 'custom_repository': {'uri': 'uri_value'}}, 'apt_repository': {'public_repository': {'repository_base': 1, 'repository_path': 'repository_path_value'}, 'custom_repository': {'uri': 'uri_value'}}, 'yum_repository': {'public_repository': {'repository_base': 1, 'repository_path': 'repository_path_value'}, 'custom_repository': {'uri': 'uri_value'}}, 'common_repository': {'uri': 'uri_value'}, 'description': 'description_value', 'upstream_credentials': {'username_password_credentials': {'username': 'username_value', 'password_secret_version': 'password_secret_version_value'}}, 'disable_upstream_validation': True}, 'name': 'projects/sample1/locations/sample2/repositories/sample3', 'format_': 1, 'description': 'description_value', 'labels': {}, 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'kms_key_name': 'kms_key_name_value', 'mode': 1, 'cleanup_policies': {}, 'size_bytes': 1089, 'satisfies_pzs': True, 'cleanup_policy_dry_run': True, 'vulnerability_scanning_config': {'enablement_config': 1, 'last_enable_time': {}, 'enablement_state': 1, 'enablement_state_reason': 'enablement_state_reason_value'}, 'disallow_unspecified_mode': True, 'satisfies_pzi': True} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_repository.UpdateRepositoryRequest.meta.fields["repository"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["repository"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["repository"][field])): - del request_init["repository"][field][i][subfield] - else: - del request_init["repository"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_repository.Repository( - name='name_value', - format_=gda_repository.Repository.Format.DOCKER, - description='description_value', - kms_key_name='kms_key_name_value', - mode=gda_repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - disallow_unspecified_mode=True, - satisfies_pzi=True, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_repository(request) - - # 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 response.mode == gda_repository.Repository.Mode.STANDARD_REPOSITORY - assert response.size_bytes == 1089 - assert response.satisfies_pzs is True - assert response.cleanup_policy_dry_run is True - assert response.disallow_unspecified_mode is True - assert response.satisfies_pzi is True - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_repository_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_repository") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_repository") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_repository.UpdateRepositoryRequest.pb(gda_repository.UpdateRepositoryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_repository.Repository.to_json(gda_repository.Repository()) - req.return_value.content = return_value - - request = gda_repository.UpdateRepositoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_repository.Repository() - - client.update_repository(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_repository_rest_bad_request(request_type=repository.DeleteRepositoryRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_repository(request) - - -@pytest.mark.parametrize("request_type", [ - repository.DeleteRepositoryRequest, - dict, -]) -def test_delete_repository_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_repository(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_repository_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_delete_repository") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_repository") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = repository.DeleteRepositoryRequest.pb(repository.DeleteRepositoryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = repository.DeleteRepositoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_repository(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_packages_rest_bad_request(request_type=package.ListPackagesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_packages(request) - - -@pytest.mark.parametrize("request_type", [ - package.ListPackagesRequest, - dict, -]) -def test_list_packages_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = package.ListPackagesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = package.ListPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_packages(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPackagesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_packages_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_packages") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_packages") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = package.ListPackagesRequest.pb(package.ListPackagesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = package.ListPackagesResponse.to_json(package.ListPackagesResponse()) - req.return_value.content = return_value - - request = package.ListPackagesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = package.ListPackagesResponse() - - client.list_packages(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_package_rest_bad_request(request_type=package.GetPackageRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_package(request) - - -@pytest.mark.parametrize("request_type", [ - package.GetPackageRequest, - dict, -]) -def test_get_package_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = package.Package( - name='name_value', - display_name='display_name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_package(request) - - # 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.parametrize("null_interceptor", [True, False]) -def test_get_package_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_package") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_package") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = package.GetPackageRequest.pb(package.GetPackageRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = package.Package.to_json(package.Package()) - req.return_value.content = return_value - - request = package.GetPackageRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = package.Package() - - client.get_package(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_package_rest_bad_request(request_type=package.DeletePackageRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_package(request) - - -@pytest.mark.parametrize("request_type", [ - package.DeletePackageRequest, - dict, -]) -def test_delete_package_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_package(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_package_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_delete_package") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_package") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = package.DeletePackageRequest.pb(package.DeletePackageRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = package.DeletePackageRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_package(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_versions(request) - - -@pytest.mark.parametrize("request_type", [ - version.ListVersionsRequest, - dict, -]) -def test_list_versions_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = version.ListVersionsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = version.ListVersionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_versions(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_versions_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_versions") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_versions") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = version.ListVersionsRequest.pb(version.ListVersionsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = version.ListVersionsResponse.to_json(version.ListVersionsResponse()) - req.return_value.content = return_value - - request = version.ListVersionsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = version.ListVersionsResponse() - - client.list_versions(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_version(request) - - -@pytest.mark.parametrize("request_type", [ - version.GetVersionRequest, - dict, -]) -def test_get_version_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = version.Version( - name='name_value', - description='description_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = version.Version.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_version(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_version_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_version") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_version") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = version.GetVersionRequest.pb(version.GetVersionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = version.Version.to_json(version.Version()) - req.return_value.content = return_value - - request = version.GetVersionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = version.Version() - - client.get_version(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_version_rest_bad_request(request_type=version.DeleteVersionRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_version(request) - - -@pytest.mark.parametrize("request_type", [ - version.DeleteVersionRequest, - dict, -]) -def test_delete_version_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_version(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_version_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_delete_version") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_version") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = version.DeleteVersionRequest.pb(version.DeleteVersionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = version.DeleteVersionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_version(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_batch_delete_versions_rest_bad_request(request_type=version.BatchDeleteVersionsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.batch_delete_versions(request) - - -@pytest.mark.parametrize("request_type", [ - version.BatchDeleteVersionsRequest, - dict, -]) -def test_batch_delete_versions_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.batch_delete_versions(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_delete_versions_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_batch_delete_versions") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_batch_delete_versions") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = version.BatchDeleteVersionsRequest.pb(version.BatchDeleteVersionsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = version.BatchDeleteVersionsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.batch_delete_versions(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_version_rest_bad_request(request_type=gda_version.UpdateVersionRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'version': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_version(request) - - -@pytest.mark.parametrize("request_type", [ - gda_version.UpdateVersionRequest, - dict, -]) -def test_update_version_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'version': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'}} - request_init["version"] = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5', 'description': 'description_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'related_tags': [{'name': 'name_value', 'version': 'version_value'}], 'metadata': {'fields': {}}, 'annotations': {}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_version.UpdateVersionRequest.meta.fields["version"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["version"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["version"][field])): - del request_init["version"][field][i][subfield] - else: - del request_init["version"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_version.Version( - name='name_value', - description='description_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_version.Version.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_version(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_version.Version) - assert response.name == 'name_value' - assert response.description == 'description_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_version_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_version") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_version") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_version.UpdateVersionRequest.pb(gda_version.UpdateVersionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_version.Version.to_json(gda_version.Version()) - req.return_value.content = return_value - - request = gda_version.UpdateVersionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_version.Version() - - client.update_version(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_files_rest_bad_request(request_type=file.ListFilesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_files(request) - - -@pytest.mark.parametrize("request_type", [ - file.ListFilesRequest, - dict, -]) -def test_list_files_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = file.ListFilesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = file.ListFilesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_files(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_files_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_files") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_files") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = file.ListFilesRequest.pb(file.ListFilesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = file.ListFilesResponse.to_json(file.ListFilesResponse()) - req.return_value.content = return_value - - request = file.ListFilesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = file.ListFilesResponse() - - client.list_files(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_file_rest_bad_request(request_type=file.GetFileRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_file(request) - - -@pytest.mark.parametrize("request_type", [ - file.GetFileRequest, - dict, -]) -def test_get_file_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = file.File.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_file(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_file_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_file") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_file") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = file.GetFileRequest.pb(file.GetFileRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = file.File.to_json(file.File()) - req.return_value.content = return_value - - request = file.GetFileRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = file.File() - - client.get_file(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_file_rest_bad_request(request_type=file.DeleteFileRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_file(request) - - -@pytest.mark.parametrize("request_type", [ - file.DeleteFileRequest, - dict, -]) -def test_delete_file_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_file(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_file_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_delete_file") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_file") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = file.DeleteFileRequest.pb(file.DeleteFileRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = file.DeleteFileRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_file(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_file_rest_bad_request(request_type=gda_file.UpdateFileRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'file': {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_file(request) - - -@pytest.mark.parametrize("request_type", [ - gda_file.UpdateFileRequest, - dict, -]) -def test_update_file_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'file': {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'}} - request_init["file"] = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4', 'size_bytes': 1089, 'hashes': [{'type_': 1, 'value': b'value_blob'}], 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'owner': 'owner_value', 'fetch_time': {}, 'annotations': {}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_file.UpdateFileRequest.meta.fields["file"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["file"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["file"][field])): - del request_init["file"][field][i][subfield] - else: - del request_init["file"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_file.File.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_file(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_file_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_file") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_file") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_file.UpdateFileRequest.pb(gda_file.UpdateFileRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_file.File.to_json(gda_file.File()) - req.return_value.content = return_value - - request = gda_file.UpdateFileRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_file.File() - - client.update_file(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_tags_rest_bad_request(request_type=tag.ListTagsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_tags(request) - - -@pytest.mark.parametrize("request_type", [ - tag.ListTagsRequest, - dict, -]) -def test_list_tags_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = tag.ListTagsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = tag.ListTagsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_tags(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_tags_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_tags") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_tags") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = tag.ListTagsRequest.pb(tag.ListTagsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = tag.ListTagsResponse.to_json(tag.ListTagsResponse()) - req.return_value.content = return_value - - request = tag.ListTagsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = tag.ListTagsResponse() - - client.list_tags(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_tag_rest_bad_request(request_type=tag.GetTagRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_tag(request) - - -@pytest.mark.parametrize("request_type", [ - tag.GetTagRequest, - dict, -]) -def test_get_tag_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = tag.Tag( - name='name_value', - version='version_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_tag(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) - assert response.name == 'name_value' - assert response.version == 'version_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_tag_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_tag") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_tag") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = tag.GetTagRequest.pb(tag.GetTagRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = tag.Tag.to_json(tag.Tag()) - req.return_value.content = return_value - - request = tag.GetTagRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = tag.Tag() - - client.get_tag(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_tag_rest_bad_request(request_type=gda_tag.CreateTagRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.create_tag(request) - - -@pytest.mark.parametrize("request_type", [ - gda_tag.CreateTagRequest, - dict, -]) -def test_create_tag_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request_init["tag"] = {'name': 'name_value', 'version': 'version_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_tag.CreateTagRequest.meta.fields["tag"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["tag"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["tag"][field])): - del request_init["tag"][field][i][subfield] - else: - del request_init["tag"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag( - name='name_value', - version='version_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_tag(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_tag_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_create_tag") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_create_tag") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_tag.CreateTagRequest.pb(gda_tag.CreateTagRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_tag.Tag.to_json(gda_tag.Tag()) - req.return_value.content = return_value - - request = gda_tag.CreateTagRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_tag.Tag() - - client.create_tag(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_tag_rest_bad_request(request_type=gda_tag.UpdateTagRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'tag': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_tag(request) - - -@pytest.mark.parametrize("request_type", [ - gda_tag.UpdateTagRequest, - dict, -]) -def test_update_tag_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'tag': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'}} - request_init["tag"] = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5', 'version': 'version_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_tag.UpdateTagRequest.meta.fields["tag"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["tag"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["tag"][field])): - del request_init["tag"][field][i][subfield] - else: - del request_init["tag"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag( - name='name_value', - version='version_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_tag(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_tag_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_tag") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_tag") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_tag.UpdateTagRequest.pb(gda_tag.UpdateTagRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_tag.Tag.to_json(gda_tag.Tag()) - req.return_value.content = return_value - - request = gda_tag.UpdateTagRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_tag.Tag() - - client.update_tag(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_tag_rest_bad_request(request_type=tag.DeleteTagRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_tag(request) - - -@pytest.mark.parametrize("request_type", [ - tag.DeleteTagRequest, - dict, -]) -def test_delete_tag_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = '' - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_tag(request) - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_tag_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_tag") as pre: - pre.assert_not_called() - pb_message = tag.DeleteTagRequest.pb(tag.DeleteTagRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - - request = tag.DeleteTagRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_tag(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_create_rule_rest_bad_request(request_type=gda_rule.CreateRuleRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.create_rule(request) - - -@pytest.mark.parametrize("request_type", [ - gda_rule.CreateRuleRequest, - dict, -]) -def test_create_rule_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request_init["rule"] = {'name': 'name_value', 'action': 1, 'operation': 1, 'condition': {'expression': 'expression_value', 'title': 'title_value', 'description': 'description_value', 'location': 'location_value'}, 'package_id': 'package_id_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_rule.CreateRuleRequest.meta.fields["rule"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["rule"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["rule"][field])): - del request_init["rule"][field][i][subfield] - else: - del request_init["rule"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_rule.Rule( - name='name_value', - action=gda_rule.Rule.Action.ALLOW, - operation=gda_rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_rule.Rule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_rule(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_rule.Rule) - assert response.name == 'name_value' - assert response.action == gda_rule.Rule.Action.ALLOW - assert response.operation == gda_rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_rule_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_create_rule") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_create_rule") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_rule.CreateRuleRequest.pb(gda_rule.CreateRuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_rule.Rule.to_json(gda_rule.Rule()) - req.return_value.content = return_value - - request = gda_rule.CreateRuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_rule.Rule() - - client.create_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_rules_rest_bad_request(request_type=rule.ListRulesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_rules(request) - - -@pytest.mark.parametrize("request_type", [ - rule.ListRulesRequest, - dict, -]) -def test_list_rules_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = rule.ListRulesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = rule.ListRulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_rules(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRulesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_rules_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_rules") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_rules") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = rule.ListRulesRequest.pb(rule.ListRulesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = rule.ListRulesResponse.to_json(rule.ListRulesResponse()) - req.return_value.content = return_value - - request = rule.ListRulesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = rule.ListRulesResponse() - - client.list_rules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_rule_rest_bad_request(request_type=rule.GetRuleRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_rule(request) - - -@pytest.mark.parametrize("request_type", [ - rule.GetRuleRequest, - dict, -]) -def test_get_rule_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = rule.Rule( - name='name_value', - action=rule.Rule.Action.ALLOW, - operation=rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = rule.Rule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_rule(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, rule.Rule) - assert response.name == 'name_value' - assert response.action == rule.Rule.Action.ALLOW - assert response.operation == rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_rule_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_rule") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_rule") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = rule.GetRuleRequest.pb(rule.GetRuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = rule.Rule.to_json(rule.Rule()) - req.return_value.content = return_value - - request = rule.GetRuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = rule.Rule() - - client.get_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_rule_rest_bad_request(request_type=gda_rule.UpdateRuleRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'rule': {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_rule(request) - - -@pytest.mark.parametrize("request_type", [ - gda_rule.UpdateRuleRequest, - dict, -]) -def test_update_rule_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'rule': {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'}} - request_init["rule"] = {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4', 'action': 1, 'operation': 1, 'condition': {'expression': 'expression_value', 'title': 'title_value', 'description': 'description_value', 'location': 'location_value'}, 'package_id': 'package_id_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_rule.UpdateRuleRequest.meta.fields["rule"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["rule"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["rule"][field])): - del request_init["rule"][field][i][subfield] - else: - del request_init["rule"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_rule.Rule( - name='name_value', - action=gda_rule.Rule.Action.ALLOW, - operation=gda_rule.Rule.Operation.DOWNLOAD, - package_id='package_id_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_rule.Rule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_rule(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_rule.Rule) - assert response.name == 'name_value' - assert response.action == gda_rule.Rule.Action.ALLOW - assert response.operation == gda_rule.Rule.Operation.DOWNLOAD - assert response.package_id == 'package_id_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_rule_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_rule") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_rule") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_rule.UpdateRuleRequest.pb(gda_rule.UpdateRuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_rule.Rule.to_json(gda_rule.Rule()) - req.return_value.content = return_value - - request = gda_rule.UpdateRuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_rule.Rule() - - client.update_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_rule_rest_bad_request(request_type=rule.DeleteRuleRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_rule(request) - - -@pytest.mark.parametrize("request_type", [ - rule.DeleteRuleRequest, - dict, -]) -def test_delete_rule_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/rules/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = '' - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_rule(request) - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_rule_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_rule") as pre: - pre.assert_not_called() - pb_message = rule.DeleteRuleRequest.pb(rule.DeleteRuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - - request = rule.DeleteRuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_rule(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_set_iam_policy_rest_bad_request(request_type=iam_policy_pb2.SetIamPolicyRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.set_iam_policy(request) - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.SetIamPolicyRequest, - dict, -]) -def test_set_iam_policy_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy( - version=774, - etag=b'etag_blob', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.set_iam_policy(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_iam_policy_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_set_iam_policy") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_set_iam_policy") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = iam_policy_pb2.SetIamPolicyRequest() - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(policy_pb2.Policy()) - req.return_value.content = return_value - - request = iam_policy_pb2.SetIamPolicyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = policy_pb2.Policy() - - client.set_iam_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_iam_policy_rest_bad_request(request_type=iam_policy_pb2.GetIamPolicyRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_iam_policy(request) - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.GetIamPolicyRequest, - dict, -]) -def test_get_iam_policy_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy( - version=774, - etag=b'etag_blob', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_iam_policy(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_iam_policy_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_iam_policy") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_iam_policy") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = iam_policy_pb2.GetIamPolicyRequest() - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(policy_pb2.Policy()) - req.return_value.content = return_value - - request = iam_policy_pb2.GetIamPolicyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = policy_pb2.Policy() - - client.get_iam_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_test_iam_permissions_rest_bad_request(request_type=iam_policy_pb2.TestIamPermissionsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.test_iam_permissions(request) - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.TestIamPermissionsRequest, - dict, -]) -def test_test_iam_permissions_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=['permissions_value'], - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.test_iam_permissions(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ['permissions_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_test_iam_permissions_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_test_iam_permissions") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_test_iam_permissions") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = iam_policy_pb2.TestIamPermissionsRequest() - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(iam_policy_pb2.TestIamPermissionsResponse()) - req.return_value.content = return_value - - request = iam_policy_pb2.TestIamPermissionsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = iam_policy_pb2.TestIamPermissionsResponse() - - client.test_iam_permissions(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_project_settings_rest_bad_request(request_type=settings.GetProjectSettingsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/projectSettings'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_project_settings(request) - - -@pytest.mark.parametrize("request_type", [ - settings.GetProjectSettingsRequest, - dict, -]) -def test_get_project_settings_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/projectSettings'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - pull_percent=1293, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_project_settings(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) - assert response.name == 'name_value' - assert response.legacy_redirection_state == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - assert response.pull_percent == 1293 - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_project_settings_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_project_settings") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_project_settings") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = settings.GetProjectSettingsRequest.pb(settings.GetProjectSettingsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) - req.return_value.content = return_value - - request = settings.GetProjectSettingsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = settings.ProjectSettings() - - client.get_project_settings(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_project_settings_rest_bad_request(request_type=settings.UpdateProjectSettingsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'project_settings': {'name': 'projects/sample1/projectSettings'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_project_settings(request) - - -@pytest.mark.parametrize("request_type", [ - settings.UpdateProjectSettingsRequest, - dict, -]) -def test_update_project_settings_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'project_settings': {'name': 'projects/sample1/projectSettings'}} - request_init["project_settings"] = {'name': 'projects/sample1/projectSettings', 'legacy_redirection_state': 1, 'pull_percent': 1293} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = settings.UpdateProjectSettingsRequest.meta.fields["project_settings"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["project_settings"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["project_settings"][field])): - del request_init["project_settings"][field][i][subfield] - else: - del request_init["project_settings"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - pull_percent=1293, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_project_settings(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) - assert response.name == 'name_value' - assert response.legacy_redirection_state == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - assert response.pull_percent == 1293 - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_project_settings_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_project_settings") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_project_settings") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = settings.UpdateProjectSettingsRequest.pb(settings.UpdateProjectSettingsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) - req.return_value.content = return_value - - request = settings.UpdateProjectSettingsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = settings.ProjectSettings() - - client.update_project_settings(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_vpcsc_config_rest_bad_request(request_type=vpcsc_config.GetVPCSCConfigRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vpcscConfig'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_vpcsc_config(request) - - -@pytest.mark.parametrize("request_type", [ - vpcsc_config.GetVPCSCConfigRequest, - dict, -]) -def test_get_vpcsc_config_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vpcscConfig'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = vpcsc_config.VPCSCConfig( - name='name_value', - vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = vpcsc_config.VPCSCConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_vpcsc_config(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, vpcsc_config.VPCSCConfig) - assert response.name == 'name_value' - assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_vpcsc_config_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_vpcsc_config") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_vpcsc_config") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = vpcsc_config.GetVPCSCConfigRequest.pb(vpcsc_config.GetVPCSCConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = vpcsc_config.VPCSCConfig.to_json(vpcsc_config.VPCSCConfig()) - req.return_value.content = return_value - - request = vpcsc_config.GetVPCSCConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = vpcsc_config.VPCSCConfig() - - client.get_vpcsc_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_vpcsc_config_rest_bad_request(request_type=gda_vpcsc_config.UpdateVPCSCConfigRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'vpcsc_config': {'name': 'projects/sample1/locations/sample2/vpcscConfig'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_vpcsc_config(request) - - -@pytest.mark.parametrize("request_type", [ - gda_vpcsc_config.UpdateVPCSCConfigRequest, - dict, -]) -def test_update_vpcsc_config_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'vpcsc_config': {'name': 'projects/sample1/locations/sample2/vpcscConfig'}} - request_init["vpcsc_config"] = {'name': 'projects/sample1/locations/sample2/vpcscConfig', 'vpcsc_policy': 1} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_vpcsc_config.UpdateVPCSCConfigRequest.meta.fields["vpcsc_config"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["vpcsc_config"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["vpcsc_config"][field])): - del request_init["vpcsc_config"][field][i][subfield] - else: - del request_init["vpcsc_config"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_vpcsc_config.VPCSCConfig( - name='name_value', - vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_vpcsc_config.VPCSCConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_vpcsc_config(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_vpcsc_config.VPCSCConfig) - assert response.name == 'name_value' - assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_vpcsc_config_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_vpcsc_config") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_vpcsc_config") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_vpcsc_config.UpdateVPCSCConfigRequest.pb(gda_vpcsc_config.UpdateVPCSCConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_vpcsc_config.VPCSCConfig.to_json(gda_vpcsc_config.VPCSCConfig()) - req.return_value.content = return_value - - request = gda_vpcsc_config.UpdateVPCSCConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_vpcsc_config.VPCSCConfig() - - client.update_vpcsc_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_package_rest_bad_request(request_type=gda_package.UpdatePackageRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'package': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_package(request) - - -@pytest.mark.parametrize("request_type", [ - gda_package.UpdatePackageRequest, - dict, -]) -def test_update_package_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'package': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'}} - request_init["package"] = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4', 'display_name': 'display_name_value', 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'annotations': {}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_package.UpdatePackageRequest.meta.fields["package"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["package"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["package"][field])): - del request_init["package"][field][i][subfield] - else: - del request_init["package"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_package.Package( - name='name_value', - display_name='display_name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_package(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, gda_package.Package) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_package_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_package") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_package") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_package.UpdatePackageRequest.pb(gda_package.UpdatePackageRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_package.Package.to_json(gda_package.Package()) - req.return_value.content = return_value - - request = gda_package.UpdatePackageRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_package.Package() - - client.update_package(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_attachments_rest_bad_request(request_type=attachment.ListAttachmentsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_attachments(request) - - -@pytest.mark.parametrize("request_type", [ - attachment.ListAttachmentsRequest, - dict, -]) -def test_list_attachments_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = attachment.ListAttachmentsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = attachment.ListAttachmentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_attachments(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAttachmentsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_attachments_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_attachments") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_attachments") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = attachment.ListAttachmentsRequest.pb(attachment.ListAttachmentsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = attachment.ListAttachmentsResponse.to_json(attachment.ListAttachmentsResponse()) - req.return_value.content = return_value - - request = attachment.ListAttachmentsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = attachment.ListAttachmentsResponse() - - client.list_attachments(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_attachment_rest_bad_request(request_type=attachment.GetAttachmentRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/attachments/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_attachment(request) - - -@pytest.mark.parametrize("request_type", [ - attachment.GetAttachmentRequest, - dict, -]) -def test_get_attachment_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/attachments/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = attachment.Attachment( - name='name_value', - target='target_value', - type_='type__value', - attachment_namespace='attachment_namespace_value', - files=['files_value'], - oci_version_name='oci_version_name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = attachment.Attachment.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_attachment(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, attachment.Attachment) - assert response.name == 'name_value' - assert response.target == 'target_value' - assert response.type_ == 'type__value' - assert response.attachment_namespace == 'attachment_namespace_value' - assert response.files == ['files_value'] - assert response.oci_version_name == 'oci_version_name_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_attachment_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_attachment") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_attachment") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = attachment.GetAttachmentRequest.pb(attachment.GetAttachmentRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = attachment.Attachment.to_json(attachment.Attachment()) - req.return_value.content = return_value - - request = attachment.GetAttachmentRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = attachment.Attachment() - - client.get_attachment(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_attachment_rest_bad_request(request_type=gda_attachment.CreateAttachmentRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.create_attachment(request) - - -@pytest.mark.parametrize("request_type", [ - gda_attachment.CreateAttachmentRequest, - dict, -]) -def test_create_attachment_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request_init["attachment"] = {'name': 'name_value', 'target': 'target_value', 'type_': 'type__value', 'attachment_namespace': 'attachment_namespace_value', 'annotations': {}, 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'files': ['files_value1', 'files_value2'], 'oci_version_name': 'oci_version_name_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_attachment.CreateAttachmentRequest.meta.fields["attachment"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["attachment"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["attachment"][field])): - del request_init["attachment"][field][i][subfield] - else: - del request_init["attachment"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_attachment(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_attachment_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_create_attachment") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_create_attachment") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_attachment.CreateAttachmentRequest.pb(gda_attachment.CreateAttachmentRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gda_attachment.CreateAttachmentRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_attachment(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_attachment_rest_bad_request(request_type=attachment.DeleteAttachmentRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/attachments/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_attachment(request) - - -@pytest.mark.parametrize("request_type", [ - attachment.DeleteAttachmentRequest, - dict, -]) -def test_delete_attachment_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/attachments/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_attachment(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_attachment_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_delete_attachment") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_attachment") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = attachment.DeleteAttachmentRequest.pb(attachment.DeleteAttachmentRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = attachment.DeleteAttachmentRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_attachment(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_location(request) - - -@pytest.mark.parametrize("request_type", [ - locations_pb2.GetLocationRequest, - dict, -]) -def test_get_location_rest(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.Location() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - - response = client.get_location(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.Location) - - -def test_list_locations_rest_bad_request(request_type=locations_pb2.ListLocationsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_locations(request) - - -@pytest.mark.parametrize("request_type", [ - locations_pb2.ListLocationsRequest, - dict, -]) -def test_list_locations_rest(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.ListLocationsResponse() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - - response = client.list_locations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) - - -def test_get_operation_rest_bad_request(request_type=operations_pb2.GetOperationRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_operation(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.GetOperationRequest, - dict, -]) -def test_get_operation_rest(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - - response = client.get_operation(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) - -def test_initialize_client_w_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - assert client is not None - - -# 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_docker_images_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), - '__call__') as call: - client.list_docker_images(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListDockerImagesRequest() - - assert args[0] == request_msg - - -# 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_get_docker_image_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_docker_image), - '__call__') as call: - client.get_docker_image(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetDockerImageRequest() - - assert args[0] == request_msg - - -# 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_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_maven_artifacts), - '__call__') as call: - client.list_maven_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListMavenArtifactsRequest() - - assert args[0] == request_msg - - -# 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_get_maven_artifact_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_maven_artifact), - '__call__') as call: - client.get_maven_artifact(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetMavenArtifactRequest() - - assert args[0] == request_msg - - -# 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_npm_packages_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_npm_packages), - '__call__') as call: - client.list_npm_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListNpmPackagesRequest() - - assert args[0] == request_msg - - -# 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_get_npm_package_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_npm_package), - '__call__') as call: - client.get_npm_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetNpmPackageRequest() - - assert args[0] == request_msg - - -# 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_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), - '__call__') as call: - client.list_python_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListPythonPackagesRequest() - - assert args[0] == request_msg - - -# 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_get_python_package_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_python_package), - '__call__') as call: - client.get_python_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetPythonPackageRequest() - - assert args[0] == request_msg - - -# 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_import_apt_artifacts_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.import_apt_artifacts), - '__call__') as call: - client.import_apt_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = apt_artifact.ImportAptArtifactsRequest() - - assert args[0] == request_msg - - -# 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_import_yum_artifacts_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.import_yum_artifacts), - '__call__') as call: - client.import_yum_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = yum_artifact.ImportYumArtifactsRequest() - - assert args[0] == request_msg - - -# 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_repositories_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_repositories), - '__call__') as call: - client.list_repositories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.ListRepositoriesRequest() - - assert args[0] == request_msg - - -# 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_get_repository_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_repository), - '__call__') as call: - client.get_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.GetRepositoryRequest() - - assert args[0] == request_msg - - -# 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_create_repository_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_repository), - '__call__') as call: - client.create_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.CreateRepositoryRequest() - - assert args[0] == request_msg - - -# 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_update_repository_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_repository), - '__call__') as call: - client.update_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.UpdateRepositoryRequest() - - assert args[0] == request_msg - - -# 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_delete_repository_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_repository), - '__call__') as call: - client.delete_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.DeleteRepositoryRequest() - - assert args[0] == request_msg - - -# 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_packages_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_packages), - '__call__') as call: - client.list_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.ListPackagesRequest() - - assert args[0] == request_msg - - -# 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_get_package_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_package), - '__call__') as call: - client.get_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.GetPackageRequest() - - assert args[0] == request_msg - - -# 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_delete_package_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_package), - '__call__') as call: - client.delete_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.DeletePackageRequest() - - assert args[0] == request_msg - - -# 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_versions_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - client.list_versions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.ListVersionsRequest() - - assert args[0] == request_msg - - -# 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_get_version_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - client.get_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.GetVersionRequest() - - assert args[0] == request_msg - - -# 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_delete_version_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - client.delete_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.DeleteVersionRequest() - - assert args[0] == request_msg - - -# 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_batch_delete_versions_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), - '__call__') as call: - client.batch_delete_versions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.BatchDeleteVersionsRequest() - - assert args[0] == request_msg - - -# 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_update_version_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_version), - '__call__') as call: - client.update_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_version.UpdateVersionRequest() - - assert args[0] == request_msg - - -# 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_files_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - client.list_files(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.ListFilesRequest() - - assert args[0] == request_msg - - -# 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_get_file_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - client.get_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.GetFileRequest() - - assert args[0] == request_msg - - -# 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_delete_file_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_file), - '__call__') as call: - client.delete_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.DeleteFileRequest() - - assert args[0] == request_msg - - -# 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_update_file_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_file), - '__call__') as call: - client.update_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_file.UpdateFileRequest() - - assert args[0] == request_msg - - -# 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_tags_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_tags), - '__call__') as call: - client.list_tags(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.ListTagsRequest() - - assert args[0] == request_msg - - -# 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_get_tag_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - client.get_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.GetTagRequest() - - assert args[0] == request_msg - - -# 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_create_tag_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_tag), - '__call__') as call: - client.create_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.CreateTagRequest() - - assert args[0] == request_msg - - -# 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_update_tag_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_tag), - '__call__') as call: - client.update_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.UpdateTagRequest() - - assert args[0] == request_msg - - -# 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_delete_tag_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - client.delete_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.DeleteTagRequest() - - assert args[0] == request_msg - - -# 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_create_rule_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_rule), - '__call__') as call: - client.create_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_rule.CreateRuleRequest() - - assert args[0] == request_msg - - -# 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_rules_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_rules), - '__call__') as call: - client.list_rules(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.ListRulesRequest() - - assert args[0] == request_msg - - -# 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_get_rule_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_rule), - '__call__') as call: - client.get_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.GetRuleRequest() - - assert args[0] == request_msg - - -# 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_update_rule_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_rule), - '__call__') as call: - client.update_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_rule.UpdateRuleRequest() - - assert args[0] == request_msg - - -# 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_delete_rule_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_rule), - '__call__') as call: - client.delete_rule(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = rule.DeleteRuleRequest() - - assert args[0] == request_msg - - -# 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_set_iam_policy_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy), - '__call__') as call: - client.set_iam_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() - - assert args[0] == request_msg - - -# 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_get_iam_policy_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy), - '__call__') as call: - client.get_iam_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() - - assert args[0] == request_msg - - -# 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_test_iam_permissions_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), - '__call__') as call: - client.test_iam_permissions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() - - assert args[0] == request_msg - - -# 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_get_project_settings_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_project_settings), - '__call__') as call: - client.get_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.GetProjectSettingsRequest() - - assert args[0] == request_msg - - -# 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_update_project_settings_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_project_settings), - '__call__') as call: - client.update_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.UpdateProjectSettingsRequest() - - assert args[0] == request_msg - - -# 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_get_vpcsc_config_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vpcsc_config), - '__call__') as call: - client.get_vpcsc_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = vpcsc_config.GetVPCSCConfigRequest() - - assert args[0] == request_msg - - -# 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_update_vpcsc_config_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), - '__call__') as call: - client.update_vpcsc_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_vpcsc_config.UpdateVPCSCConfigRequest() - - assert args[0] == request_msg - - -# 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_update_package_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_package), - '__call__') as call: - client.update_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_package.UpdatePackageRequest() - - assert args[0] == request_msg - - -# 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_attachments_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_attachments), - '__call__') as call: - client.list_attachments(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.ListAttachmentsRequest() - - assert args[0] == request_msg - - -# 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_get_attachment_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_attachment), - '__call__') as call: - client.get_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.GetAttachmentRequest() - - assert args[0] == request_msg - - -# 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_create_attachment_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_attachment), - '__call__') as call: - client.create_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_attachment.CreateAttachmentRequest() - - assert args[0] == request_msg - - -# 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_delete_attachment_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_attachment), - '__call__') as call: - client.delete_attachment(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = attachment.DeleteAttachmentRequest() - - assert args[0] == request_msg - - -def test_artifact_registry_rest_lro_client(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - transport = client.transport - - # Ensure that we have an api-core operations client. - assert isinstance( - transport.operations_client, -operations_v1.AbstractOperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.ArtifactRegistryGrpcTransport, - ) - -def test_artifact_registry_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.ArtifactRegistryTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_artifact_registry_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.artifactregistry_v1.services.artifact_registry.transports.ArtifactRegistryTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.ArtifactRegistryTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - 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', - 'get_repository', - 'create_repository', - 'update_repository', - 'delete_repository', - 'list_packages', - 'get_package', - 'delete_package', - 'list_versions', - 'get_version', - 'delete_version', - 'batch_delete_versions', - 'update_version', - 'list_files', - 'get_file', - 'delete_file', - 'update_file', - 'list_tags', - 'get_tag', - 'create_tag', - 'update_tag', - 'delete_tag', - 'create_rule', - 'list_rules', - 'get_rule', - 'update_rule', - 'delete_rule', - 'set_iam_policy', - 'get_iam_policy', - 'test_iam_permissions', - 'get_project_settings', - 'update_project_settings', - 'get_vpcsc_config', - 'update_vpcsc_config', - 'update_package', - 'list_attachments', - 'get_attachment', - 'create_attachment', - 'delete_attachment', - 'get_location', - 'list_locations', - 'get_operation', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - # Catch all for all remaining methods and properties - remainder = [ - 'kind', - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_artifact_registry_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.artifactregistry_v1.services.artifact_registry.transports.ArtifactRegistryTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ArtifactRegistryTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', -), - quota_project_id="octopus", - ) - - -def test_artifact_registry_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.artifactregistry_v1.services.artifact_registry.transports.ArtifactRegistryTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ArtifactRegistryTransport() - adc.assert_called_once() - - -def test_artifact_registry_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - ArtifactRegistryClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', -), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryGrpcAsyncIOTransport, - ], -) -def test_artifact_registry_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-platform.read-only',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryGrpcAsyncIOTransport, - transports.ArtifactRegistryRestTransport, - ], -) -def test_artifact_registry_transport_auth_gdch_credentials(transport_class): - host = 'https://language.com' - api_audience_tests = [None, 'https://language2.com'] - api_audience_expect = [host, 'https://language2.com'] - for t, e in zip(api_audience_tests, api_audience_expect): - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - gdch_mock = mock.MagicMock() - type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) - adc.return_value = (gdch_mock, None) - transport_class(host=host, api_audience=t) - gdch_mock.with_gdch_audience.assert_called_once_with( - e - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.ArtifactRegistryGrpcTransport, grpc_helpers), - (transports.ArtifactRegistryGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_artifact_registry_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "artifactregistry.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', -), - scopes=["1", "2"], - default_host="artifactregistry.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.ArtifactRegistryGrpcTransport, transports.ArtifactRegistryGrpcAsyncIOTransport]) -def test_artifact_registry_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key - ) - -def test_artifact_registry_http_transport_client_cert_source_for_mtls(): - cred = ga_credentials.AnonymousCredentials() - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: - transports.ArtifactRegistryRestTransport ( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) - - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_artifact_registry_host_no_port(transport_name): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='artifactregistry.googleapis.com'), - transport=transport_name, - ) - assert client.transport._host == ( - 'artifactregistry.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://artifactregistry.googleapis.com' - ) - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_artifact_registry_host_with_port(transport_name): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='artifactregistry.googleapis.com:8000'), - transport=transport_name, - ) - assert client.transport._host == ( - 'artifactregistry.googleapis.com:8000' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://artifactregistry.googleapis.com:8000' - ) - -@pytest.mark.parametrize("transport_name", [ - "rest", -]) -def test_artifact_registry_client_transport_session_collision(transport_name): - creds1 = ga_credentials.AnonymousCredentials() - creds2 = ga_credentials.AnonymousCredentials() - client1 = ArtifactRegistryClient( - credentials=creds1, - transport=transport_name, - ) - client2 = ArtifactRegistryClient( - credentials=creds2, - transport=transport_name, - ) - session1 = client1.transport.list_docker_images._session - session2 = client2.transport.list_docker_images._session - assert session1 != session2 - session1 = client1.transport.get_docker_image._session - session2 = client2.transport.get_docker_image._session - assert session1 != session2 - session1 = client1.transport.list_maven_artifacts._session - session2 = client2.transport.list_maven_artifacts._session - assert session1 != session2 - session1 = client1.transport.get_maven_artifact._session - session2 = client2.transport.get_maven_artifact._session - assert session1 != session2 - session1 = client1.transport.list_npm_packages._session - session2 = client2.transport.list_npm_packages._session - assert session1 != session2 - session1 = client1.transport.get_npm_package._session - session2 = client2.transport.get_npm_package._session - assert session1 != session2 - session1 = client1.transport.list_python_packages._session - session2 = client2.transport.list_python_packages._session - assert session1 != session2 - session1 = client1.transport.get_python_package._session - session2 = client2.transport.get_python_package._session - assert session1 != session2 - session1 = client1.transport.import_apt_artifacts._session - session2 = client2.transport.import_apt_artifacts._session - assert session1 != session2 - session1 = client1.transport.import_yum_artifacts._session - session2 = client2.transport.import_yum_artifacts._session - assert session1 != session2 - session1 = client1.transport.list_repositories._session - session2 = client2.transport.list_repositories._session - assert session1 != session2 - session1 = client1.transport.get_repository._session - session2 = client2.transport.get_repository._session - assert session1 != session2 - session1 = client1.transport.create_repository._session - session2 = client2.transport.create_repository._session - assert session1 != session2 - session1 = client1.transport.update_repository._session - session2 = client2.transport.update_repository._session - assert session1 != session2 - session1 = client1.transport.delete_repository._session - session2 = client2.transport.delete_repository._session - assert session1 != session2 - session1 = client1.transport.list_packages._session - session2 = client2.transport.list_packages._session - assert session1 != session2 - session1 = client1.transport.get_package._session - session2 = client2.transport.get_package._session - assert session1 != session2 - session1 = client1.transport.delete_package._session - session2 = client2.transport.delete_package._session - assert session1 != session2 - session1 = client1.transport.list_versions._session - session2 = client2.transport.list_versions._session - assert session1 != session2 - session1 = client1.transport.get_version._session - session2 = client2.transport.get_version._session - assert session1 != session2 - session1 = client1.transport.delete_version._session - session2 = client2.transport.delete_version._session - assert session1 != session2 - session1 = client1.transport.batch_delete_versions._session - session2 = client2.transport.batch_delete_versions._session - assert session1 != session2 - session1 = client1.transport.update_version._session - session2 = client2.transport.update_version._session - assert session1 != session2 - session1 = client1.transport.list_files._session - session2 = client2.transport.list_files._session - assert session1 != session2 - session1 = client1.transport.get_file._session - session2 = client2.transport.get_file._session - assert session1 != session2 - session1 = client1.transport.delete_file._session - session2 = client2.transport.delete_file._session - assert session1 != session2 - session1 = client1.transport.update_file._session - session2 = client2.transport.update_file._session - assert session1 != session2 - session1 = client1.transport.list_tags._session - session2 = client2.transport.list_tags._session - assert session1 != session2 - session1 = client1.transport.get_tag._session - session2 = client2.transport.get_tag._session - assert session1 != session2 - session1 = client1.transport.create_tag._session - session2 = client2.transport.create_tag._session - assert session1 != session2 - session1 = client1.transport.update_tag._session - session2 = client2.transport.update_tag._session - assert session1 != session2 - session1 = client1.transport.delete_tag._session - session2 = client2.transport.delete_tag._session - assert session1 != session2 - session1 = client1.transport.create_rule._session - session2 = client2.transport.create_rule._session - assert session1 != session2 - session1 = client1.transport.list_rules._session - session2 = client2.transport.list_rules._session - assert session1 != session2 - session1 = client1.transport.get_rule._session - session2 = client2.transport.get_rule._session - assert session1 != session2 - session1 = client1.transport.update_rule._session - session2 = client2.transport.update_rule._session - assert session1 != session2 - session1 = client1.transport.delete_rule._session - session2 = client2.transport.delete_rule._session - assert session1 != session2 - session1 = client1.transport.set_iam_policy._session - session2 = client2.transport.set_iam_policy._session - assert session1 != session2 - session1 = client1.transport.get_iam_policy._session - session2 = client2.transport.get_iam_policy._session - assert session1 != session2 - session1 = client1.transport.test_iam_permissions._session - session2 = client2.transport.test_iam_permissions._session - assert session1 != session2 - session1 = client1.transport.get_project_settings._session - session2 = client2.transport.get_project_settings._session - assert session1 != session2 - session1 = client1.transport.update_project_settings._session - session2 = client2.transport.update_project_settings._session - assert session1 != session2 - session1 = client1.transport.get_vpcsc_config._session - session2 = client2.transport.get_vpcsc_config._session - assert session1 != session2 - session1 = client1.transport.update_vpcsc_config._session - session2 = client2.transport.update_vpcsc_config._session - assert session1 != session2 - session1 = client1.transport.update_package._session - session2 = client2.transport.update_package._session - assert session1 != session2 - session1 = client1.transport.list_attachments._session - session2 = client2.transport.list_attachments._session - assert session1 != session2 - session1 = client1.transport.get_attachment._session - session2 = client2.transport.get_attachment._session - assert session1 != session2 - session1 = client1.transport.create_attachment._session - session2 = client2.transport.create_attachment._session - assert session1 != session2 - session1 = client1.transport.delete_attachment._session - session2 = client2.transport.delete_attachment._session - assert session1 != session2 -def test_artifact_registry_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ArtifactRegistryGrpcTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_artifact_registry_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ArtifactRegistryGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.ArtifactRegistryGrpcTransport, transports.ArtifactRegistryGrpcAsyncIOTransport]) -def test_artifact_registry_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.ArtifactRegistryGrpcTransport, transports.ArtifactRegistryGrpcAsyncIOTransport]) -def test_artifact_registry_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_artifact_registry_grpc_lro_client(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_artifact_registry_grpc_lro_async_client(): - client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_apt_artifact_path(): - project = "squid" - location = "clam" - repository = "whelk" - apt_artifact = "octopus" - expected = "projects/{project}/locations/{location}/repositories/{repository}/aptArtifacts/{apt_artifact}".format(project=project, location=location, repository=repository, apt_artifact=apt_artifact, ) - actual = ArtifactRegistryClient.apt_artifact_path(project, location, repository, apt_artifact) - assert expected == actual - - -def test_parse_apt_artifact_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "repository": "cuttlefish", - "apt_artifact": "mussel", - } - path = ArtifactRegistryClient.apt_artifact_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_apt_artifact_path(path) - assert expected == actual - -def test_attachment_path(): - project = "winkle" - location = "nautilus" - repository = "scallop" - attachment = "abalone" - expected = "projects/{project}/locations/{location}/repositories/{repository}/attachments/{attachment}".format(project=project, location=location, repository=repository, attachment=attachment, ) - actual = ArtifactRegistryClient.attachment_path(project, location, repository, attachment) - assert expected == actual - - -def test_parse_attachment_path(): - expected = { - "project": "squid", - "location": "clam", - "repository": "whelk", - "attachment": "octopus", - } - path = ArtifactRegistryClient.attachment_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_attachment_path(path) - assert expected == actual - -def test_docker_image_path(): - project = "oyster" - location = "nudibranch" - repository = "cuttlefish" - docker_image = "mussel" - expected = "projects/{project}/locations/{location}/repositories/{repository}/dockerImages/{docker_image}".format(project=project, location=location, repository=repository, docker_image=docker_image, ) - actual = ArtifactRegistryClient.docker_image_path(project, location, repository, docker_image) - assert expected == actual - - -def test_parse_docker_image_path(): - expected = { - "project": "winkle", - "location": "nautilus", - "repository": "scallop", - "docker_image": "abalone", - } - path = ArtifactRegistryClient.docker_image_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_docker_image_path(path) - assert expected == actual - -def test_file_path(): - project = "squid" - location = "clam" - repository = "whelk" - file = "octopus" - expected = "projects/{project}/locations/{location}/repositories/{repository}/files/{file}".format(project=project, location=location, repository=repository, file=file, ) - actual = ArtifactRegistryClient.file_path(project, location, repository, file) - assert expected == actual - - -def test_parse_file_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "repository": "cuttlefish", - "file": "mussel", - } - path = ArtifactRegistryClient.file_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_file_path(path) - assert expected == actual - -def test_maven_artifact_path(): - project = "winkle" - location = "nautilus" - repository = "scallop" - maven_artifact = "abalone" - 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": "squid", - "location": "clam", - "repository": "whelk", - "maven_artifact": "octopus", - } - 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 = "oyster" - location = "nudibranch" - repository = "cuttlefish" - npm_package = "mussel" - 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": "winkle", - "location": "nautilus", - "repository": "scallop", - "npm_package": "abalone", - } - 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 = "squid" - location = "clam" - repository = "whelk" - package = "octopus" - 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": "oyster", - "location": "nudibranch", - "repository": "cuttlefish", - "package": "mussel", - } - 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 = "winkle" - expected = "projects/{project}/projectSettings".format(project=project, ) - actual = ArtifactRegistryClient.project_settings_path(project) - assert expected == actual - - -def test_parse_project_settings_path(): - expected = { - "project": "nautilus", - } - path = ArtifactRegistryClient.project_settings_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_project_settings_path(path) - assert expected == actual - -def test_python_package_path(): - project = "scallop" - location = "abalone" - repository = "squid" - python_package = "clam" - 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": "whelk", - "location": "octopus", - "repository": "oyster", - "python_package": "nudibranch", - } - 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 = "cuttlefish" - location = "mussel" - repository = "winkle" - expected = "projects/{project}/locations/{location}/repositories/{repository}".format(project=project, location=location, repository=repository, ) - actual = ArtifactRegistryClient.repository_path(project, location, repository) - assert expected == actual - - -def test_parse_repository_path(): - expected = { - "project": "nautilus", - "location": "scallop", - "repository": "abalone", - } - path = ArtifactRegistryClient.repository_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_repository_path(path) - assert expected == actual - -def test_rule_path(): - project = "squid" - location = "clam" - repository = "whelk" - rule = "octopus" - expected = "projects/{project}/locations/{location}/repositories/{repository}/rules/{rule}".format(project=project, location=location, repository=repository, rule=rule, ) - actual = ArtifactRegistryClient.rule_path(project, location, repository, rule) - assert expected == actual - - -def test_parse_rule_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "repository": "cuttlefish", - "rule": "mussel", - } - path = ArtifactRegistryClient.rule_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_rule_path(path) - assert expected == actual - -def test_secret_version_path(): - project = "winkle" - secret = "nautilus" - secret_version = "scallop" - expected = "projects/{project}/secrets/{secret}/versions/{secret_version}".format(project=project, secret=secret, secret_version=secret_version, ) - actual = ArtifactRegistryClient.secret_version_path(project, secret, secret_version) - assert expected == actual - - -def test_parse_secret_version_path(): - expected = { - "project": "abalone", - "secret": "squid", - "secret_version": "clam", - } - path = ArtifactRegistryClient.secret_version_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_secret_version_path(path) - assert expected == actual - -def test_tag_path(): - project = "whelk" - location = "octopus" - repository = "oyster" - package = "nudibranch" - tag = "cuttlefish" - expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag}".format(project=project, location=location, repository=repository, package=package, tag=tag, ) - actual = ArtifactRegistryClient.tag_path(project, location, repository, package, tag) - assert expected == actual - - -def test_parse_tag_path(): - expected = { - "project": "mussel", - "location": "winkle", - "repository": "nautilus", - "package": "scallop", - "tag": "abalone", - } - path = ArtifactRegistryClient.tag_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_tag_path(path) - assert expected == actual - -def test_version_path(): - project = "squid" - location = "clam" - repository = "whelk" - package = "octopus" - version = "oyster" - expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/versions/{version}".format(project=project, location=location, repository=repository, package=package, version=version, ) - actual = ArtifactRegistryClient.version_path(project, location, repository, package, version) - assert expected == actual - - -def test_parse_version_path(): - expected = { - "project": "nudibranch", - "location": "cuttlefish", - "repository": "mussel", - "package": "winkle", - "version": "nautilus", - } - path = ArtifactRegistryClient.version_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_version_path(path) - assert expected == actual - -def test_vpcsc_config_path(): - project = "scallop" - location = "abalone" - 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": "squid", - "location": "clam", - } - 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 = "whelk" - location = "octopus" - repository = "oyster" - yum_artifact = "nudibranch" - expected = "projects/{project}/locations/{location}/repositories/{repository}/yumArtifacts/{yum_artifact}".format(project=project, location=location, repository=repository, yum_artifact=yum_artifact, ) - actual = ArtifactRegistryClient.yum_artifact_path(project, location, repository, yum_artifact) - assert expected == actual - - -def test_parse_yum_artifact_path(): - expected = { - "project": "cuttlefish", - "location": "mussel", - "repository": "winkle", - "yum_artifact": "nautilus", - } - path = ArtifactRegistryClient.yum_artifact_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_yum_artifact_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "scallop" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = ArtifactRegistryClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "abalone", - } - path = ArtifactRegistryClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "squid" - expected = "folders/{folder}".format(folder=folder, ) - actual = ArtifactRegistryClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "clam", - } - path = ArtifactRegistryClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "whelk" - expected = "organizations/{organization}".format(organization=organization, ) - actual = ArtifactRegistryClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "octopus", - } - path = ArtifactRegistryClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "oyster" - expected = "projects/{project}".format(project=project, ) - actual = ArtifactRegistryClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "nudibranch", - } - path = ArtifactRegistryClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "cuttlefish" - location = "mussel" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = ArtifactRegistryClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "winkle", - "location": "nautilus", - } - path = ArtifactRegistryClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_with_default_client_info(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.ArtifactRegistryTransport, '_prep_wrapped_messages') as prep: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.ArtifactRegistryTransport, '_prep_wrapped_messages') as prep: - transport_class = ArtifactRegistryClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - -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_asyncio"): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - # 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(), 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 = locations_pb2.ListLocationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.ListLocationsResponse() - response = client.list_locations(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, locations_pb2.ListLocationsResponse) -@pytest.mark.asyncio -async def test_list_locations_async(transport: str = "grpc_asyncio"): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), 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 = locations_pb2.ListLocationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - response = await client.list_locations(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, locations_pb2.ListLocationsResponse) - -def test_list_locations_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 = locations_pb2.ListLocationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - call.return_value = locations_pb2.ListLocationsResponse() - - client.list_locations(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_list_locations_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = locations_pb2.ListLocationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - await client.list_locations(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_list_locations_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.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.ListLocationsResponse() - - response = client.list_locations( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_list_locations_from_dict_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - response = await client.list_locations( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_get_location(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 = locations_pb2.GetLocationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.Location() - response = client.get_location(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, locations_pb2.Location) -@pytest.mark.asyncio -async def test_get_location_async(transport: str = "grpc_asyncio"): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), 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 = locations_pb2.GetLocationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - response = await client.get_location(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, locations_pb2.Location) - -def test_get_location_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 = locations_pb2.GetLocationRequest() - request.name = "locations/abc" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - call.return_value = locations_pb2.Location() - - client.get_location(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/abc",) in kw["metadata"] -@pytest.mark.asyncio -async def test_get_location_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials() - ) - - # 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 = locations_pb2.GetLocationRequest() - request.name = "locations/abc" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - await client.get_location(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/abc",) in kw["metadata"] - -def test_get_location_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.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.Location() - - response = client.get_location( - request={ - "name": "locations/abc", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_get_location_from_dict_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - response = await client.get_location( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_transport_close_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc" - ) - with mock.patch.object(type(getattr(client.transport, "_grpc_channel")), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -@pytest.mark.asyncio -async def test_transport_close_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio" - ) - with mock.patch.object(type(getattr(client.transport, "_grpc_channel")), "close") as close: - async with client: - close.assert_not_called() - close.assert_called_once() - - -def test_transport_close_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - with mock.patch.object(type(getattr(client.transport, "_session")), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -def test_client_ctx(): - transports = [ - 'rest', - 'grpc', - ] - for transport in transports: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() - -@pytest.mark.parametrize("client_class,transport_class", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport), -]) -def test_api_key_credentials(client_class, transport_class): - with mock.patch.object( - google.auth._default, "get_api_key_credentials", create=True - ) as get_api_key_credentials: - mock_cred = mock.Mock() - get_api_key_credentials.return_value = mock_cred - options = client_options.ClientOptions() - options.api_key = "api_key" - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=mock_cred, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/.coveragerc b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/.coveragerc deleted file mode 100644 index 5fe8843f3d6f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -[report] -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 - # Ignore debug-only repr - def __repr__ diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/.flake8 b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/.flake8 deleted file mode 100644 index 29227d4cf419..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/.flake8 +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://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 by synthtool. DO NOT EDIT! -[flake8] -ignore = E203, E266, E501, W503 -exclude = - # Exclude generated code. - **/proto/** - **/gapic/** - **/services/** - **/types/** - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/MANIFEST.in b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/MANIFEST.in deleted file mode 100644 index 7f3b00917047..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/artifactregistry *.py -recursive-include google/cloud/artifactregistry_v1beta2 *.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/README.rst b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/README.rst deleted file mode 100644 index 2a03378bed7f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Artifactregistry API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Artifactregistry API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/_static/custom.css b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/_static/custom.css deleted file mode 100644 index 06423be0b592..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/_static/custom.css +++ /dev/null @@ -1,3 +0,0 @@ -dl.field-list > dt { - min-width: 100px -} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/artifact_registry.rst b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/artifact_registry.rst deleted file mode 100644 index f067de34041c..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/artifact_registry.rst +++ /dev/null @@ -1,10 +0,0 @@ -ArtifactRegistry ----------------------------------- - -.. automodule:: google.cloud.artifactregistry_v1beta2.services.artifact_registry - :members: - :inherited-members: - -.. automodule:: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/services_.rst b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/services_.rst deleted file mode 100644 index 5bcc4462e7f6..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/services_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Artifactregistry v1beta2 API -====================================================== -.. toctree:: - :maxdepth: 2 - - artifact_registry diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/types_.rst b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/types_.rst deleted file mode 100644 index 987b230b174e..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/artifactregistry_v1beta2/types_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Types for Google Cloud Artifactregistry v1beta2 API -=================================================== - -.. automodule:: google.cloud.artifactregistry_v1beta2.types - :members: - :show-inheritance: diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/conf.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/conf.py deleted file mode 100644 index 68e126a263bf..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -# -# google-cloud-artifact-registry documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "4.0.1" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The root toctree document. -root_doc = "index" - -# General information about the project. -project = u"google-cloud-artifact-registry" -copyright = u"2023, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = 'en' - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-artifact-registry-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - root_doc, - "google-cloud-artifact-registry.tex", - u"google-cloud-artifact-registry Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - root_doc, - "google-cloud-artifact-registry", - u"Google Cloud Artifactregistry Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - root_doc, - "google-cloud-artifact-registry", - u"google-cloud-artifact-registry Documentation", - author, - "google-cloud-artifact-registry", - "GAPIC library for Google Cloud Artifactregistry API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/index.rst b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/index.rst deleted file mode 100644 index dcf887cef4af..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - artifactregistry_v1beta2/services_ - artifactregistry_v1beta2/types_ diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/__init__.py deleted file mode 100644 index abc6c5e61e8e..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/__init__.py +++ /dev/null @@ -1,119 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 google.cloud.artifactregistry import gapic_version as package_version - -__version__ = package_version.__version__ - - -from google.cloud.artifactregistry_v1beta2.services.artifact_registry.client import ArtifactRegistryClient -from google.cloud.artifactregistry_v1beta2.services.artifact_registry.async_client import ArtifactRegistryAsyncClient - -from google.cloud.artifactregistry_v1beta2.types.apt_artifact import AptArtifact -from google.cloud.artifactregistry_v1beta2.types.apt_artifact import ImportAptArtifactsErrorInfo -from google.cloud.artifactregistry_v1beta2.types.apt_artifact import ImportAptArtifactsGcsSource -from google.cloud.artifactregistry_v1beta2.types.apt_artifact import ImportAptArtifactsMetadata -from google.cloud.artifactregistry_v1beta2.types.apt_artifact import ImportAptArtifactsRequest -from google.cloud.artifactregistry_v1beta2.types.apt_artifact import ImportAptArtifactsResponse -from google.cloud.artifactregistry_v1beta2.types.file import File -from google.cloud.artifactregistry_v1beta2.types.file import GetFileRequest -from google.cloud.artifactregistry_v1beta2.types.file import Hash -from google.cloud.artifactregistry_v1beta2.types.file import ListFilesRequest -from google.cloud.artifactregistry_v1beta2.types.file import ListFilesResponse -from google.cloud.artifactregistry_v1beta2.types.package import DeletePackageRequest -from google.cloud.artifactregistry_v1beta2.types.package import GetPackageRequest -from google.cloud.artifactregistry_v1beta2.types.package import ListPackagesRequest -from google.cloud.artifactregistry_v1beta2.types.package import ListPackagesResponse -from google.cloud.artifactregistry_v1beta2.types.package import Package -from google.cloud.artifactregistry_v1beta2.types.repository import CreateRepositoryRequest -from google.cloud.artifactregistry_v1beta2.types.repository import DeleteRepositoryRequest -from google.cloud.artifactregistry_v1beta2.types.repository import GetRepositoryRequest -from google.cloud.artifactregistry_v1beta2.types.repository import ListRepositoriesRequest -from google.cloud.artifactregistry_v1beta2.types.repository import ListRepositoriesResponse -from google.cloud.artifactregistry_v1beta2.types.repository import Repository -from google.cloud.artifactregistry_v1beta2.types.repository import UpdateRepositoryRequest -from google.cloud.artifactregistry_v1beta2.types.service import OperationMetadata -from google.cloud.artifactregistry_v1beta2.types.settings import GetProjectSettingsRequest -from google.cloud.artifactregistry_v1beta2.types.settings import ProjectSettings -from google.cloud.artifactregistry_v1beta2.types.settings import UpdateProjectSettingsRequest -from google.cloud.artifactregistry_v1beta2.types.tag import CreateTagRequest -from google.cloud.artifactregistry_v1beta2.types.tag import DeleteTagRequest -from google.cloud.artifactregistry_v1beta2.types.tag import GetTagRequest -from google.cloud.artifactregistry_v1beta2.types.tag import ListTagsRequest -from google.cloud.artifactregistry_v1beta2.types.tag import ListTagsResponse -from google.cloud.artifactregistry_v1beta2.types.tag import Tag -from google.cloud.artifactregistry_v1beta2.types.tag import UpdateTagRequest -from google.cloud.artifactregistry_v1beta2.types.version import DeleteVersionRequest -from google.cloud.artifactregistry_v1beta2.types.version import GetVersionRequest -from google.cloud.artifactregistry_v1beta2.types.version import ListVersionsRequest -from google.cloud.artifactregistry_v1beta2.types.version import ListVersionsResponse -from google.cloud.artifactregistry_v1beta2.types.version import Version -from google.cloud.artifactregistry_v1beta2.types.version import VersionView -from google.cloud.artifactregistry_v1beta2.types.yum_artifact import ImportYumArtifactsErrorInfo -from google.cloud.artifactregistry_v1beta2.types.yum_artifact import ImportYumArtifactsGcsSource -from google.cloud.artifactregistry_v1beta2.types.yum_artifact import ImportYumArtifactsMetadata -from google.cloud.artifactregistry_v1beta2.types.yum_artifact import ImportYumArtifactsRequest -from google.cloud.artifactregistry_v1beta2.types.yum_artifact import ImportYumArtifactsResponse -from google.cloud.artifactregistry_v1beta2.types.yum_artifact import YumArtifact - -__all__ = ('ArtifactRegistryClient', - 'ArtifactRegistryAsyncClient', - 'AptArtifact', - 'ImportAptArtifactsErrorInfo', - 'ImportAptArtifactsGcsSource', - 'ImportAptArtifactsMetadata', - 'ImportAptArtifactsRequest', - 'ImportAptArtifactsResponse', - 'File', - 'GetFileRequest', - 'Hash', - 'ListFilesRequest', - 'ListFilesResponse', - 'DeletePackageRequest', - 'GetPackageRequest', - 'ListPackagesRequest', - 'ListPackagesResponse', - 'Package', - 'CreateRepositoryRequest', - 'DeleteRepositoryRequest', - 'GetRepositoryRequest', - 'ListRepositoriesRequest', - 'ListRepositoriesResponse', - 'Repository', - 'UpdateRepositoryRequest', - 'OperationMetadata', - 'GetProjectSettingsRequest', - 'ProjectSettings', - 'UpdateProjectSettingsRequest', - 'CreateTagRequest', - 'DeleteTagRequest', - 'GetTagRequest', - 'ListTagsRequest', - 'ListTagsResponse', - 'Tag', - 'UpdateTagRequest', - 'DeleteVersionRequest', - 'GetVersionRequest', - 'ListVersionsRequest', - 'ListVersionsResponse', - 'Version', - 'VersionView', - 'ImportYumArtifactsErrorInfo', - 'ImportYumArtifactsGcsSource', - 'ImportYumArtifactsMetadata', - 'ImportYumArtifactsRequest', - 'ImportYumArtifactsResponse', - 'YumArtifact', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/gapic_version.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/gapic_version.py deleted file mode 100644 index 558c8aab67c5..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/py.typed b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/py.typed deleted file mode 100644 index 7ee239890682..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-artifact-registry package uses inline types. diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/__init__.py deleted file mode 100644 index bad63c2491b8..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/__init__.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 google.cloud.artifactregistry_v1beta2 import gapic_version as package_version - -__version__ = package_version.__version__ - - -from .services.artifact_registry import ArtifactRegistryClient -from .services.artifact_registry import ArtifactRegistryAsyncClient - -from .types.apt_artifact import AptArtifact -from .types.apt_artifact import ImportAptArtifactsErrorInfo -from .types.apt_artifact import ImportAptArtifactsGcsSource -from .types.apt_artifact import ImportAptArtifactsMetadata -from .types.apt_artifact import ImportAptArtifactsRequest -from .types.apt_artifact import ImportAptArtifactsResponse -from .types.file import File -from .types.file import GetFileRequest -from .types.file import Hash -from .types.file import ListFilesRequest -from .types.file import ListFilesResponse -from .types.package import DeletePackageRequest -from .types.package import GetPackageRequest -from .types.package import ListPackagesRequest -from .types.package import ListPackagesResponse -from .types.package import Package -from .types.repository import CreateRepositoryRequest -from .types.repository import DeleteRepositoryRequest -from .types.repository import GetRepositoryRequest -from .types.repository import ListRepositoriesRequest -from .types.repository import ListRepositoriesResponse -from .types.repository import Repository -from .types.repository import UpdateRepositoryRequest -from .types.service import OperationMetadata -from .types.settings import GetProjectSettingsRequest -from .types.settings import ProjectSettings -from .types.settings import UpdateProjectSettingsRequest -from .types.tag import CreateTagRequest -from .types.tag import DeleteTagRequest -from .types.tag import GetTagRequest -from .types.tag import ListTagsRequest -from .types.tag import ListTagsResponse -from .types.tag import Tag -from .types.tag import UpdateTagRequest -from .types.version import DeleteVersionRequest -from .types.version import GetVersionRequest -from .types.version import ListVersionsRequest -from .types.version import ListVersionsResponse -from .types.version import Version -from .types.version import VersionView -from .types.yum_artifact import ImportYumArtifactsErrorInfo -from .types.yum_artifact import ImportYumArtifactsGcsSource -from .types.yum_artifact import ImportYumArtifactsMetadata -from .types.yum_artifact import ImportYumArtifactsRequest -from .types.yum_artifact import ImportYumArtifactsResponse -from .types.yum_artifact import YumArtifact - -__all__ = ( - 'ArtifactRegistryAsyncClient', -'AptArtifact', -'ArtifactRegistryClient', -'CreateRepositoryRequest', -'CreateTagRequest', -'DeletePackageRequest', -'DeleteRepositoryRequest', -'DeleteTagRequest', -'DeleteVersionRequest', -'File', -'GetFileRequest', -'GetPackageRequest', -'GetProjectSettingsRequest', -'GetRepositoryRequest', -'GetTagRequest', -'GetVersionRequest', -'Hash', -'ImportAptArtifactsErrorInfo', -'ImportAptArtifactsGcsSource', -'ImportAptArtifactsMetadata', -'ImportAptArtifactsRequest', -'ImportAptArtifactsResponse', -'ImportYumArtifactsErrorInfo', -'ImportYumArtifactsGcsSource', -'ImportYumArtifactsMetadata', -'ImportYumArtifactsRequest', -'ImportYumArtifactsResponse', -'ListFilesRequest', -'ListFilesResponse', -'ListPackagesRequest', -'ListPackagesResponse', -'ListRepositoriesRequest', -'ListRepositoriesResponse', -'ListTagsRequest', -'ListTagsResponse', -'ListVersionsRequest', -'ListVersionsResponse', -'OperationMetadata', -'Package', -'ProjectSettings', -'Repository', -'Tag', -'UpdateProjectSettingsRequest', -'UpdateRepositoryRequest', -'UpdateTagRequest', -'Version', -'VersionView', -'YumArtifact', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/gapic_metadata.json b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/gapic_metadata.json deleted file mode 100644 index da884cc9006b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/gapic_metadata.json +++ /dev/null @@ -1,403 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.artifactregistry_v1beta2", - "protoPackage": "google.devtools.artifactregistry.v1beta2", - "schema": "1.0", - "services": { - "ArtifactRegistry": { - "clients": { - "grpc": { - "libraryClient": "ArtifactRegistryClient", - "rpcs": { - "CreateRepository": { - "methods": [ - "create_repository" - ] - }, - "CreateTag": { - "methods": [ - "create_tag" - ] - }, - "DeletePackage": { - "methods": [ - "delete_package" - ] - }, - "DeleteRepository": { - "methods": [ - "delete_repository" - ] - }, - "DeleteTag": { - "methods": [ - "delete_tag" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetFile": { - "methods": [ - "get_file" - ] - }, - "GetIamPolicy": { - "methods": [ - "get_iam_policy" - ] - }, - "GetPackage": { - "methods": [ - "get_package" - ] - }, - "GetProjectSettings": { - "methods": [ - "get_project_settings" - ] - }, - "GetRepository": { - "methods": [ - "get_repository" - ] - }, - "GetTag": { - "methods": [ - "get_tag" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ImportAptArtifacts": { - "methods": [ - "import_apt_artifacts" - ] - }, - "ImportYumArtifacts": { - "methods": [ - "import_yum_artifacts" - ] - }, - "ListFiles": { - "methods": [ - "list_files" - ] - }, - "ListPackages": { - "methods": [ - "list_packages" - ] - }, - "ListRepositories": { - "methods": [ - "list_repositories" - ] - }, - "ListTags": { - "methods": [ - "list_tags" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "SetIamPolicy": { - "methods": [ - "set_iam_policy" - ] - }, - "TestIamPermissions": { - "methods": [ - "test_iam_permissions" - ] - }, - "UpdateProjectSettings": { - "methods": [ - "update_project_settings" - ] - }, - "UpdateRepository": { - "methods": [ - "update_repository" - ] - }, - "UpdateTag": { - "methods": [ - "update_tag" - ] - } - } - }, - "grpc-async": { - "libraryClient": "ArtifactRegistryAsyncClient", - "rpcs": { - "CreateRepository": { - "methods": [ - "create_repository" - ] - }, - "CreateTag": { - "methods": [ - "create_tag" - ] - }, - "DeletePackage": { - "methods": [ - "delete_package" - ] - }, - "DeleteRepository": { - "methods": [ - "delete_repository" - ] - }, - "DeleteTag": { - "methods": [ - "delete_tag" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetFile": { - "methods": [ - "get_file" - ] - }, - "GetIamPolicy": { - "methods": [ - "get_iam_policy" - ] - }, - "GetPackage": { - "methods": [ - "get_package" - ] - }, - "GetProjectSettings": { - "methods": [ - "get_project_settings" - ] - }, - "GetRepository": { - "methods": [ - "get_repository" - ] - }, - "GetTag": { - "methods": [ - "get_tag" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ImportAptArtifacts": { - "methods": [ - "import_apt_artifacts" - ] - }, - "ImportYumArtifacts": { - "methods": [ - "import_yum_artifacts" - ] - }, - "ListFiles": { - "methods": [ - "list_files" - ] - }, - "ListPackages": { - "methods": [ - "list_packages" - ] - }, - "ListRepositories": { - "methods": [ - "list_repositories" - ] - }, - "ListTags": { - "methods": [ - "list_tags" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "SetIamPolicy": { - "methods": [ - "set_iam_policy" - ] - }, - "TestIamPermissions": { - "methods": [ - "test_iam_permissions" - ] - }, - "UpdateProjectSettings": { - "methods": [ - "update_project_settings" - ] - }, - "UpdateRepository": { - "methods": [ - "update_repository" - ] - }, - "UpdateTag": { - "methods": [ - "update_tag" - ] - } - } - }, - "rest": { - "libraryClient": "ArtifactRegistryClient", - "rpcs": { - "CreateRepository": { - "methods": [ - "create_repository" - ] - }, - "CreateTag": { - "methods": [ - "create_tag" - ] - }, - "DeletePackage": { - "methods": [ - "delete_package" - ] - }, - "DeleteRepository": { - "methods": [ - "delete_repository" - ] - }, - "DeleteTag": { - "methods": [ - "delete_tag" - ] - }, - "DeleteVersion": { - "methods": [ - "delete_version" - ] - }, - "GetFile": { - "methods": [ - "get_file" - ] - }, - "GetIamPolicy": { - "methods": [ - "get_iam_policy" - ] - }, - "GetPackage": { - "methods": [ - "get_package" - ] - }, - "GetProjectSettings": { - "methods": [ - "get_project_settings" - ] - }, - "GetRepository": { - "methods": [ - "get_repository" - ] - }, - "GetTag": { - "methods": [ - "get_tag" - ] - }, - "GetVersion": { - "methods": [ - "get_version" - ] - }, - "ImportAptArtifacts": { - "methods": [ - "import_apt_artifacts" - ] - }, - "ImportYumArtifacts": { - "methods": [ - "import_yum_artifacts" - ] - }, - "ListFiles": { - "methods": [ - "list_files" - ] - }, - "ListPackages": { - "methods": [ - "list_packages" - ] - }, - "ListRepositories": { - "methods": [ - "list_repositories" - ] - }, - "ListTags": { - "methods": [ - "list_tags" - ] - }, - "ListVersions": { - "methods": [ - "list_versions" - ] - }, - "SetIamPolicy": { - "methods": [ - "set_iam_policy" - ] - }, - "TestIamPermissions": { - "methods": [ - "test_iam_permissions" - ] - }, - "UpdateProjectSettings": { - "methods": [ - "update_project_settings" - ] - }, - "UpdateRepository": { - "methods": [ - "update_repository" - ] - }, - "UpdateTag": { - "methods": [ - "update_tag" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/gapic_version.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/gapic_version.py deleted file mode 100644 index 558c8aab67c5..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/py.typed b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/py.typed deleted file mode 100644 index 7ee239890682..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-artifact-registry package uses inline types. diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/__init__.py deleted file mode 100644 index 8f6cf068242c..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/__init__.py deleted file mode 100644 index e174d42fd497..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 .client import ArtifactRegistryClient -from .async_client import ArtifactRegistryAsyncClient - -__all__ = ( - 'ArtifactRegistryClient', - 'ArtifactRegistryAsyncClient', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py deleted file mode 100644 index 5e0f84240c67..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py +++ /dev/null @@ -1,3139 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 collections import OrderedDict -import re -from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union - -from google.cloud.artifactregistry_v1beta2 import gapic_version as package_version - -from google.api_core.client_options import ClientOptions -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry_async as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - - -try: - OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.artifactregistry_v1beta2.services.artifact_registry import pagers -from google.cloud.artifactregistry_v1beta2.types import apt_artifact -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository -from google.cloud.artifactregistry_v1beta2.types import service -from google.cloud.artifactregistry_v1beta2.types import settings -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag -from google.cloud.artifactregistry_v1beta2.types import version -from google.cloud.artifactregistry_v1beta2.types import yum_artifact -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.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport -from .client import ArtifactRegistryClient - - -class ArtifactRegistryAsyncClient: - """The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - """ - - _client: ArtifactRegistryClient - - # Copy defaults from the synchronous client for use here. - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = ArtifactRegistryClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - _DEFAULT_ENDPOINT_TEMPLATE = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE - _DEFAULT_UNIVERSE = ArtifactRegistryClient._DEFAULT_UNIVERSE - - apt_artifact_path = staticmethod(ArtifactRegistryClient.apt_artifact_path) - parse_apt_artifact_path = staticmethod(ArtifactRegistryClient.parse_apt_artifact_path) - file_path = staticmethod(ArtifactRegistryClient.file_path) - parse_file_path = staticmethod(ArtifactRegistryClient.parse_file_path) - project_settings_path = staticmethod(ArtifactRegistryClient.project_settings_path) - parse_project_settings_path = staticmethod(ArtifactRegistryClient.parse_project_settings_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) - yum_artifact_path = staticmethod(ArtifactRegistryClient.yum_artifact_path) - parse_yum_artifact_path = staticmethod(ArtifactRegistryClient.parse_yum_artifact_path) - common_billing_account_path = staticmethod(ArtifactRegistryClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(ArtifactRegistryClient.parse_common_billing_account_path) - common_folder_path = staticmethod(ArtifactRegistryClient.common_folder_path) - parse_common_folder_path = staticmethod(ArtifactRegistryClient.parse_common_folder_path) - common_organization_path = staticmethod(ArtifactRegistryClient.common_organization_path) - parse_common_organization_path = staticmethod(ArtifactRegistryClient.parse_common_organization_path) - common_project_path = staticmethod(ArtifactRegistryClient.common_project_path) - parse_common_project_path = staticmethod(ArtifactRegistryClient.parse_common_project_path) - common_location_path = staticmethod(ArtifactRegistryClient.common_location_path) - parse_common_location_path = staticmethod(ArtifactRegistryClient.parse_common_location_path) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ArtifactRegistryAsyncClient: The constructed client. - """ - return ArtifactRegistryClient.from_service_account_info.__func__(ArtifactRegistryAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ArtifactRegistryAsyncClient: The constructed client. - """ - return ArtifactRegistryClient.from_service_account_file.__func__(ArtifactRegistryAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[ClientOptions] = None): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - return ArtifactRegistryClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> ArtifactRegistryTransport: - """Returns the transport used by the client instance. - - Returns: - ArtifactRegistryTransport: The transport used by the client instance. - """ - return self._client.transport - - @property - def api_endpoint(self): - """Return the API endpoint used by the client instance. - - Returns: - str: The API endpoint used by the client instance. - """ - return self._client._api_endpoint - - @property - def universe_domain(self) -> str: - """Return the universe domain used by the client instance. - - Returns: - str: The universe domain used - by the client instance. - """ - return self._client._universe_domain - - get_transport_class = ArtifactRegistryClient.get_transport_class - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, ArtifactRegistryTransport, Callable[..., ArtifactRegistryTransport]]] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the artifact registry async client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Optional[Union[str,ArtifactRegistryTransport,Callable[..., ArtifactRegistryTransport]]]): - The transport to use, or a Callable that constructs and returns a new transport to use. - If a Callable is given, it will be called with the same set of initialization - arguments as used in the ArtifactRegistryTransport constructor. - If set to None, a transport is chosen automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): - Custom options for the client. - - 1. The ``api_endpoint`` property can be used to override the - default endpoint provided by the client when ``transport`` is - not explicitly provided. Only if this property is not set and - ``transport`` was not explicitly provided, the endpoint is - determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment - variable, which have one of the following values: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto-switch to the - default mTLS endpoint if client certificate is present; this is - the default value). - - 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide a client certificate for mTLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - 3. The ``universe_domain`` property can be used to override the - default "googleapis.com" universe. Note that ``api_endpoint`` - property still takes precedence; and ``universe_domain`` is - currently not supported for mTLS. - - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = ArtifactRegistryClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def import_apt_artifacts(self, - request: Optional[Union[apt_artifact.ImportAptArtifactsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Imports Apt artifacts. The returned Operation will - complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - .. 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_v1beta2 - - async def sample_import_apt_artifacts(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ImportAptArtifactsRequest( - ) - - # Make the request - operation = client.import_apt_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.ImportAptArtifactsRequest, dict]]): - The request object. The request to import new apt - artifacts. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1beta2.types.ImportAptArtifactsResponse` - The response message from importing APT artifacts. - - """ - # Create or coerce a protobuf request object. - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, apt_artifact.ImportAptArtifactsRequest): - request = apt_artifact.ImportAptArtifactsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.import_apt_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - apt_artifact.ImportAptArtifactsResponse, - metadata_type=apt_artifact.ImportAptArtifactsMetadata, - ) - - # Done; return the response. - return response - - async def import_yum_artifacts(self, - request: Optional[Union[yum_artifact.ImportYumArtifactsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Imports Yum (RPM) artifacts. The returned Operation - will complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - .. 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_v1beta2 - - async def sample_import_yum_artifacts(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ImportYumArtifactsRequest( - ) - - # Make the request - operation = client.import_yum_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.ImportYumArtifactsRequest, dict]]): - The request object. The request to import new yum - artifacts. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1beta2.types.ImportYumArtifactsResponse` - The response message from importing YUM artifacts. - - """ - # Create or coerce a protobuf request object. - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, yum_artifact.ImportYumArtifactsRequest): - request = yum_artifact.ImportYumArtifactsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.import_yum_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - yum_artifact.ImportYumArtifactsResponse, - metadata_type=yum_artifact.ImportYumArtifactsMetadata, - ) - - # Done; return the response. - return response - - async def list_repositories(self, - request: Optional[Union[repository.ListRepositoriesRequest, 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.ListRepositoriesAsyncPager: - r"""Lists repositories. - - .. 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_v1beta2 - - async def sample_list_repositories(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListRepositoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_repositories(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.ListRepositoriesRequest, dict]]): - The request object. The request to list repositories. - parent (:class:`str`): - Required. The name of the parent - resource whose repositories 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_async.AsyncRetry): 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_v1beta2.services.artifact_registry.pagers.ListRepositoriesAsyncPager: - The response from listing - repositories. - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.ListRepositoriesRequest): - request = repository.ListRepositoriesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_repositories] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListRepositoriesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_repository(self, - request: Optional[Union[repository.GetRepositoryRequest, 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]] = (), - ) -> repository.Repository: - r"""Gets a repository. - - .. 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_v1beta2 - - async def sample_get_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetRepositoryRequest( - name="name_value", - ) - - # Make the request - response = await client.get_repository(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.GetRepositoryRequest, dict]]): - The request object. The request to retrieve a repository. - name (:class:`str`): - Required. The name of the repository - to retrieve. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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_v1beta2.types.Repository: - A Repository for storing artifacts - with a specific format. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.GetRepositoryRequest): - request = repository.GetRepositoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_repository(self, - request: Optional[Union[gda_repository.CreateRepositoryRequest, dict]] = None, - *, - parent: Optional[str] = None, - repository: Optional[gda_repository.Repository] = None, - repository_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a repository. The returned Operation will - finish once the repository has been created. Its - response will be the created Repository. - - .. 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_v1beta2 - - async def sample_create_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.CreateRepositoryRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_repository(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.CreateRepositoryRequest, dict]]): - The request object. The request to create a new - repository. - parent (:class:`str`): - Required. The name of the parent - resource where the repository will be - created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - repository (:class:`google.cloud.artifactregistry_v1beta2.types.Repository`): - The repository to be created. - This corresponds to the ``repository`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - repository_id (:class:`str`): - The repository id to use for this - repository. - - This corresponds to the ``repository_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1beta2.types.Repository` - A Repository for storing artifacts with a specific - format. - - """ - # 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, repository, repository_id]) - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_repository.CreateRepositoryRequest): - request = gda_repository.CreateRepositoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if repository is not None: - request.repository = repository - if repository_id is not None: - request.repository_id = repository_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - gda_repository.Repository, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_repository(self, - request: Optional[Union[gda_repository.UpdateRepositoryRequest, dict]] = None, - *, - repository: Optional[gda_repository.Repository] = 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_repository.Repository: - r"""Updates a repository. - - .. 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_v1beta2 - - async def sample_update_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateRepositoryRequest( - ) - - # Make the request - response = await client.update_repository(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.UpdateRepositoryRequest, dict]]): - The request object. The request to update a repository. - repository (:class:`google.cloud.artifactregistry_v1beta2.types.Repository`): - The repository that replaces the - resource on the server. - - This corresponds to the ``repository`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): 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_v1beta2.types.Repository: - A Repository for storing artifacts - with a specific format. - - """ - # 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([repository, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_repository.UpdateRepositoryRequest): - request = gda_repository.UpdateRepositoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if repository is not None: - request.repository = repository - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.update_repository] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("repository.name", request.repository.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_repository(self, - request: Optional[Union[repository.DeleteRepositoryRequest, 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a repository and all of its contents. The - returned Operation will finish once the repository has - been deleted. It will not have any Operation metadata - and will return a google.protobuf.Empty response. - - .. 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_v1beta2 - - async def sample_delete_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteRepositoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_repository(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.DeleteRepositoryRequest, dict]]): - The request object. The request to delete a repository. - name (:class:`str`): - Required. The name of the repository - to delete. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.DeleteRepositoryRequest): - request = repository.DeleteRepositoryRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.delete_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_packages(self, - request: Optional[Union[package.ListPackagesRequest, 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.ListPackagesAsyncPager: - r"""Lists 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_v1beta2 - - async def sample_list_packages(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListPackagesRequest( - ) - - # Make the request - page_result = client.list_packages(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.ListPackagesRequest, dict]]): - The request object. The request to list packages. - parent (:class:`str`): - The name of the parent resource whose - 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_async.AsyncRetry): 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_v1beta2.services.artifact_registry.pagers.ListPackagesAsyncPager: - The response from listing 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.ListPackagesRequest): - request = package.ListPackagesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListPackagesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_package(self, - request: Optional[Union[package.GetPackageRequest, 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]] = (), - ) -> package.Package: - r"""Gets a 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_v1beta2 - - async def sample_get_package(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetPackageRequest( - ) - - # Make the request - response = await client.get_package(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.GetPackageRequest, dict]]): - The request object. The request to retrieve a package. - name (:class:`str`): - The name of the package to retrieve. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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_v1beta2.types.Package: - Packages are named collections of - versions. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.GetPackageRequest): - request = package.GetPackageRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_package(self, - request: Optional[Union[package.DeletePackageRequest, 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a package and all of its versions and tags. - The returned operation will complete once the package - has been deleted. - - .. 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_v1beta2 - - async def sample_delete_package(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeletePackageRequest( - ) - - # Make the request - operation = client.delete_package(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.DeletePackageRequest, dict]]): - The request object. The request to delete a package. - name (:class:`str`): - The name of the package to delete. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.DeletePackageRequest): - request = package.DeletePackageRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.delete_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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_versions(self, - request: Optional[Union[version.ListVersionsRequest, 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.ListVersionsAsyncPager: - r"""Lists versions. - - .. 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_v1beta2 - - async def sample_list_versions(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListVersionsRequest( - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.ListVersionsRequest, dict]]): - The request object. The request to list versions. - parent (:class:`str`): - The name of the parent resource whose - versions 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_async.AsyncRetry): 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_v1beta2.services.artifact_registry.pagers.ListVersionsAsyncPager: - The response from listing versions. - - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.ListVersionsRequest): - request = version.ListVersionsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_versions] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListVersionsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_version(self, - request: Optional[Union[version.GetVersionRequest, 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]] = (), - ) -> version.Version: - r"""Gets a version - - .. 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_v1beta2 - - async def sample_get_version(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetVersionRequest( - ) - - # Make the request - response = await client.get_version(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.GetVersionRequest, dict]]): - The request object. The request to retrieve a version. - name (:class:`str`): - The name of the version to retrieve. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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_v1beta2.types.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.GetVersionRequest): - request = version.GetVersionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_version] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_version(self, - request: Optional[Union[version.DeleteVersionRequest, 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]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes a version and all of its content. The - returned operation will complete once the version has - been deleted. - - .. 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_v1beta2 - - async def sample_delete_version(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteVersionRequest( - ) - - # Make the request - operation = client.delete_version(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.DeleteVersionRequest, dict]]): - The request object. The request to delete a version. - name (:class:`str`): - The name of the version to delete. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.DeleteVersionRequest): - request = version.DeleteVersionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.delete_version] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation_async.from_gapic( - response, - self._client._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_files(self, - request: Optional[Union[file.ListFilesRequest, 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.ListFilesAsyncPager: - r"""Lists files. - - .. 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_v1beta2 - - async def sample_list_files(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListFilesRequest( - ) - - # Make the request - page_result = client.list_files(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.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: - "projects/p1/locations/us-central1/repositories/repo1 - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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_v1beta2.services.artifact_registry.pagers.ListFilesAsyncPager: - The response from listing files. - - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.ListFilesRequest): - request = file.ListFilesRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_files] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListFilesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_file(self, - request: Optional[Union[file.GetFileRequest, 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]] = (), - ) -> file.File: - r"""Gets a file. - - .. 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_v1beta2 - - async def sample_get_file(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetFileRequest( - ) - - # Make the request - response = await client.get_file(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.GetFileRequest, dict]]): - The request object. The request to retrieve a file. - name (:class:`str`): - 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. - retry (google.api_core.retry_async.AsyncRetry): 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_v1beta2.types.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.GetFileRequest): - request = file.GetFileRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_file] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_tags(self, - request: Optional[Union[tag.ListTagsRequest, 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.ListTagsAsyncPager: - r"""Lists tags. - - .. 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_v1beta2 - - async def sample_list_tags(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListTagsRequest( - ) - - # Make the request - page_result = client.list_tags(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.ListTagsRequest, dict]]): - The request object. The request to list tags. - parent (:class:`str`): - The name of the parent resource whose - tags 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_async.AsyncRetry): 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_v1beta2.services.artifact_registry.pagers.ListTagsAsyncPager: - The response from listing tags. - - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.ListTagsRequest): - request = tag.ListTagsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.list_tags] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListTagsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_tag(self, - request: Optional[Union[tag.GetTagRequest, 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]] = (), - ) -> tag.Tag: - r"""Gets a tag. - - .. 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_v1beta2 - - async def sample_get_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetTagRequest( - ) - - # Make the request - response = await client.get_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.GetTagRequest, dict]]): - The request object. The request to retrieve a tag. - name (:class:`str`): - The name of the tag to retrieve. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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_v1beta2.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.GetTagRequest): - request = tag.GetTagRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_tag(self, - request: Optional[Union[gda_tag.CreateTagRequest, dict]] = None, - *, - parent: Optional[str] = None, - tag: Optional[gda_tag.Tag] = None, - tag_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gda_tag.Tag: - r"""Creates a tag. - - .. 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_v1beta2 - - async def sample_create_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.CreateTagRequest( - ) - - # Make the request - response = await client.create_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.CreateTagRequest, dict]]): - The request object. The request to create a new tag. - parent (:class:`str`): - The name of the parent resource where - the tag will be created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag (:class:`google.cloud.artifactregistry_v1beta2.types.Tag`): - The tag to be created. - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag_id (:class:`str`): - The tag id to use for this - repository. - - This corresponds to the ``tag_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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_v1beta2.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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, tag, tag_id]) - 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_tag.CreateTagRequest): - request = gda_tag.CreateTagRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if tag is not None: - request.tag = tag - if tag_id is not None: - request.tag_id = tag_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_tag(self, - request: Optional[Union[gda_tag.UpdateTagRequest, dict]] = None, - *, - tag: Optional[gda_tag.Tag] = 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_tag.Tag: - r"""Updates a tag. - - .. 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_v1beta2 - - async def sample_update_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateTagRequest( - ) - - # Make the request - response = await client.update_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.UpdateTagRequest, dict]]): - The request object. The request to create or update a - tag. - tag (:class:`google.cloud.artifactregistry_v1beta2.types.Tag`): - The tag that replaces the resource on - the server. - - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): 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_v1beta2.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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([tag, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_tag.UpdateTagRequest): - request = gda_tag.UpdateTagRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if tag is not None: - request.tag = tag - if update_mask is not None: - request.update_mask = update_mask - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.update_tag] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("tag.name", request.tag.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_tag(self, - request: Optional[Union[tag.DeleteTagRequest, 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]] = (), - ) -> None: - r"""Deletes a tag. - - .. 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_v1beta2 - - async def sample_delete_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteTagRequest( - ) - - # Make the request - await client.delete_tag(request=request) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.DeleteTagRequest, dict]]): - The request object. The request to delete a tag. - name (:class:`str`): - The name of the tag to delete. - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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. - """ - # 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.DeleteTagRequest): - request = tag.DeleteTagRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.delete_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - async def set_iam_policy(self, - request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Updates the IAM policy for a given resource. - - .. 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_v1beta2 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - async def sample_set_iam_policy(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = await client.set_iam_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]): - The request object. Request message for ``SetIamPolicy`` method. - retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). - - """ - # Create or coerce a protobuf request object. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.SetIamPolicyRequest(**request) - elif not request: - request = iam_policy_pb2.SetIamPolicyRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.set_iam_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_iam_policy(self, - request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Gets the IAM policy for a given resource. - - .. 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_v1beta2 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - async def sample_get_iam_policy(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = await client.get_iam_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]): - The request object. Request message for ``GetIamPolicy`` method. - retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). - - """ - # Create or coerce a protobuf request object. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.GetIamPolicyRequest(**request) - elif not request: - request = iam_policy_pb2.GetIamPolicyRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.get_iam_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def test_iam_permissions(self, - request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Tests if the caller has a list of permissions on a - resource. - - .. 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_v1beta2 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - async def sample_test_iam_permissions(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], - ) - - # Make the request - response = await client.test_iam_permissions(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]): - The request object. Request message for ``TestIamPermissions`` method. - retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: - Response message for TestIamPermissions method. - """ - # Create or coerce a protobuf request object. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.TestIamPermissionsRequest(**request) - elif not request: - request = iam_policy_pb2.TestIamPermissionsRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.test_iam_permissions] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_project_settings(self, - request: Optional[Union[settings.GetProjectSettingsRequest, 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]] = (), - ) -> settings.ProjectSettings: - r"""Retrieves the Settings 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_v1beta2 - - async def sample_get_project_settings(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetProjectSettingsRequest( - name="name_value", - ) - - # Make the request - response = await client.get_project_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.GetProjectSettingsRequest, dict]]): - The request object. Gets the redirection status for a - project. - name (:class:`str`): - Required. The name of the - projectSettings 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_async.AsyncRetry): 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_v1beta2.types.ProjectSettings: - The Artifact Registry settings 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, settings.GetProjectSettingsRequest): - request = settings.GetProjectSettingsRequest(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._client._transport._wrapped_methods[self._client._transport.get_project_settings] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_project_settings(self, - request: Optional[Union[settings.UpdateProjectSettingsRequest, dict]] = None, - *, - project_settings: Optional[settings.ProjectSettings] = 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]] = (), - ) -> settings.ProjectSettings: - r"""Updates the Settings 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_v1beta2 - - async def sample_update_project_settings(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateProjectSettingsRequest( - ) - - # Make the request - response = await client.update_project_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.artifactregistry_v1beta2.types.UpdateProjectSettingsRequest, dict]]): - The request object. Sets the settings of the project. - project_settings (:class:`google.cloud.artifactregistry_v1beta2.types.ProjectSettings`): - The project settings. - This corresponds to the ``project_settings`` 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_async.AsyncRetry): 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_v1beta2.types.ProjectSettings: - The Artifact Registry settings 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([project_settings, 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.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, settings.UpdateProjectSettingsRequest): - request = settings.UpdateProjectSettingsRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if project_settings is not None: - request.project_settings = project_settings - 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._client._transport._wrapped_methods[self._client._transport.update_project_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("project_settings.name", request.project_settings.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` method. - retry (google.api_core.retry_async.AsyncRetry): 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self.transport._wrapped_methods[self._client._transport.get_location] - - # 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),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - async def list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` method. - retry (google.api_core.retry_async.AsyncRetry): 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self.transport._wrapped_methods[self._client._transport.list_locations] - - # 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),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - async def __aenter__(self) -> "ArtifactRegistryAsyncClient": - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "ArtifactRegistryAsyncClient", -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py deleted file mode 100644 index 4d95988b61ce..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py +++ /dev/null @@ -1,3528 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 collections import OrderedDict -import os -import re -from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast -import warnings - -from google.cloud.artifactregistry_v1beta2 import gapic_version as package_version - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.artifactregistry_v1beta2.services.artifact_registry import pagers -from google.cloud.artifactregistry_v1beta2.types import apt_artifact -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository -from google.cloud.artifactregistry_v1beta2.types import service -from google.cloud.artifactregistry_v1beta2.types import settings -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag -from google.cloud.artifactregistry_v1beta2.types import version -from google.cloud.artifactregistry_v1beta2.types import yum_artifact -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.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import ArtifactRegistryGrpcTransport -from .transports.grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport -from .transports.rest import ArtifactRegistryRestTransport - - -class ArtifactRegistryClientMeta(type): - """Metaclass for the ArtifactRegistry client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - _transport_registry = OrderedDict() # type: Dict[str, Type[ArtifactRegistryTransport]] - _transport_registry["grpc"] = ArtifactRegistryGrpcTransport - _transport_registry["grpc_asyncio"] = ArtifactRegistryGrpcAsyncIOTransport - _transport_registry["rest"] = ArtifactRegistryRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[ArtifactRegistryTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class ArtifactRegistryClient(metaclass=ArtifactRegistryClientMeta): - """The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - """ - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = "artifactregistry.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - _DEFAULT_ENDPOINT_TEMPLATE = "artifactregistry.{UNIVERSE_DOMAIN}" - _DEFAULT_UNIVERSE = "googleapis.com" - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ArtifactRegistryClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - ArtifactRegistryClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file( - filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> ArtifactRegistryTransport: - """Returns the transport used by the client instance. - - Returns: - ArtifactRegistryTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def apt_artifact_path(project: str,location: str,repository: str,apt_artifact: str,) -> str: - """Returns a fully-qualified apt_artifact string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/aptArtifacts/{apt_artifact}".format(project=project, location=location, repository=repository, apt_artifact=apt_artifact, ) - - @staticmethod - def parse_apt_artifact_path(path: str) -> Dict[str,str]: - """Parses a apt_artifact path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/aptArtifacts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def file_path(project: str,location: str,repository: str,file: str,) -> str: - """Returns a fully-qualified file string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/files/{file}".format(project=project, location=location, repository=repository, file=file, ) - - @staticmethod - def parse_file_path(path: str) -> Dict[str,str]: - """Parses a file path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/files/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def project_settings_path(project: str,) -> str: - """Returns a fully-qualified project_settings string.""" - return "projects/{project}/projectSettings".format(project=project, ) - - @staticmethod - def parse_project_settings_path(path: str) -> Dict[str,str]: - """Parses a project_settings path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/projectSettings$", path) - return m.groupdict() if m else {} - - @staticmethod - def repository_path(project: str,location: str,repository: str,) -> str: - """Returns a fully-qualified repository string.""" - return "projects/{project}/locations/{location}/repositories/{repository}".format(project=project, location=location, repository=repository, ) - - @staticmethod - def parse_repository_path(path: str) -> Dict[str,str]: - """Parses a repository path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def tag_path(project: str,location: str,repository: str,package: str,tag: str,) -> str: - """Returns a fully-qualified tag string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag}".format(project=project, location=location, repository=repository, package=package, tag=tag, ) - - @staticmethod - def parse_tag_path(path: str) -> Dict[str,str]: - """Parses a tag path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/packages/(?P.+?)/tags/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def version_path(project: str,location: str,repository: str,package: str,version: str,) -> str: - """Returns a fully-qualified version string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/versions/{version}".format(project=project, location=location, repository=repository, package=package, version=version, ) - - @staticmethod - def parse_version_path(path: str) -> Dict[str,str]: - """Parses a version path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/packages/(?P.+?)/versions/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def yum_artifact_path(project: str,location: str,repository: str,yum_artifact: str,) -> str: - """Returns a fully-qualified yum_artifact string.""" - return "projects/{project}/locations/{location}/repositories/{repository}/yumArtifacts/{yum_artifact}".format(project=project, location=location, repository=repository, yum_artifact=yum_artifact, ) - - @staticmethod - def parse_yum_artifact_path(path: str) -> Dict[str,str]: - """Parses a yum_artifact path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/yumArtifacts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str, ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str, ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str, ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path(project: str, location: str, ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format(project=project, location=location, ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): - """Deprecated. Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - - warnings.warn("get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.", - DeprecationWarning) - if client_options is None: - client_options = client_options_lib.ClientOptions() - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_client_cert not in ("true", "false"): - raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") - - # Figure out the client cert source to use. - client_cert_source = None - if use_client_cert == "true": - if client_options.client_cert_source: - client_cert_source = client_options.client_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): - api_endpoint = cls.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = cls.DEFAULT_ENDPOINT - - return api_endpoint, client_cert_source - - @staticmethod - def _read_environment_variables(): - """Returns the environment variables used by the client. - - Returns: - Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, - GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. - - Raises: - ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not - any of ["true", "false"]. - google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT - is not any of ["auto", "never", "always"]. - """ - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false").lower() - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() - universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") - if use_client_cert not in ("true", "false"): - raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") - return use_client_cert == "true", use_mtls_endpoint, universe_domain_env - - @staticmethod - def _get_client_cert_source(provided_cert_source, use_cert_flag): - """Return the client cert source to be used by the client. - - Args: - provided_cert_source (bytes): The client certificate source provided. - use_cert_flag (bool): A flag indicating whether to use the client certificate. - - Returns: - bytes or None: The client cert source to be used by the client. - """ - client_cert_source = None - if use_cert_flag: - if provided_cert_source: - client_cert_source = provided_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - return client_cert_source - - @staticmethod - def _get_api_endpoint(api_override, client_cert_source, universe_domain, use_mtls_endpoint): - """Return the API endpoint used by the client. - - Args: - api_override (str): The API endpoint override. If specified, this is always - the return value of this function and the other arguments are not used. - client_cert_source (bytes): The client certificate source used by the client. - universe_domain (str): The universe domain used by the client. - use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters. - Possible values are "always", "auto", or "never". - - Returns: - str: The API endpoint to be used by the client. - """ - if api_override is not None: - api_endpoint = api_override - elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): - _default_universe = ArtifactRegistryClient._DEFAULT_UNIVERSE - if universe_domain != _default_universe: - raise MutualTLSChannelError(f"mTLS is not supported in any universe other than {_default_universe}.") - api_endpoint = ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=universe_domain) - return api_endpoint - - @staticmethod - def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str: - """Return the universe domain used by the client. - - Args: - client_universe_domain (Optional[str]): The universe domain configured via the client options. - universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable. - - Returns: - str: The universe domain to be used by the client. - - Raises: - ValueError: If the universe domain is an empty string. - """ - universe_domain = ArtifactRegistryClient._DEFAULT_UNIVERSE - if client_universe_domain is not None: - universe_domain = client_universe_domain - elif universe_domain_env is not None: - universe_domain = universe_domain_env - if len(universe_domain.strip()) == 0: - raise ValueError("Universe Domain cannot be an empty string.") - return universe_domain - - @staticmethod - def _compare_universes(client_universe: str, - credentials: ga_credentials.Credentials) -> bool: - """Returns True iff the universe domains used by the client and credentials match. - - Args: - client_universe (str): The universe domain configured via the client options. - credentials (ga_credentials.Credentials): The credentials being used in the client. - - Returns: - bool: True iff client_universe matches the universe in credentials. - - Raises: - ValueError: when client_universe does not match the universe in credentials. - """ - - default_universe = ArtifactRegistryClient._DEFAULT_UNIVERSE - credentials_universe = getattr(credentials, "universe_domain", default_universe) - - if client_universe != credentials_universe: - raise ValueError("The configured universe domain " - f"({client_universe}) does not match the universe domain " - f"found in the credentials ({credentials_universe}). " - "If you haven't configured the universe domain explicitly, " - f"`{default_universe}` is the default.") - return True - - def _validate_universe_domain(self): - """Validates client's and credentials' universe domains are consistent. - - Returns: - bool: True iff the configured universe domain is valid. - - Raises: - ValueError: If the configured universe domain is not valid. - """ - self._is_universe_domain_valid = (self._is_universe_domain_valid or - ArtifactRegistryClient._compare_universes(self.universe_domain, self.transport._credentials)) - return self._is_universe_domain_valid - - @property - def api_endpoint(self): - """Return the API endpoint used by the client instance. - - Returns: - str: The API endpoint used by the client instance. - """ - return self._api_endpoint - - @property - def universe_domain(self) -> str: - """Return the universe domain used by the client instance. - - Returns: - str: The universe domain used by the client instance. - """ - return self._universe_domain - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, ArtifactRegistryTransport, Callable[..., ArtifactRegistryTransport]]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the artifact registry client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Optional[Union[str,ArtifactRegistryTransport,Callable[..., ArtifactRegistryTransport]]]): - The transport to use, or a Callable that constructs and returns a new transport. - If a Callable is given, it will be called with the same set of initialization - arguments as used in the ArtifactRegistryTransport constructor. - If set to None, a transport is chosen automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): - Custom options for the client. - - 1. The ``api_endpoint`` property can be used to override the - default endpoint provided by the client when ``transport`` is - not explicitly provided. Only if this property is not set and - ``transport`` was not explicitly provided, the endpoint is - determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment - variable, which have one of the following values: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto-switch to the - default mTLS endpoint if client certificate is present; this is - the default value). - - 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide a client certificate for mTLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - 3. The ``universe_domain`` property can be used to override the - default "googleapis.com" universe. Note that the ``api_endpoint`` - property still takes precedence; and ``universe_domain`` is - currently not supported for mTLS. - - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client_options = client_options - if isinstance(self._client_options, dict): - self._client_options = client_options_lib.from_dict(self._client_options) - if self._client_options is None: - self._client_options = client_options_lib.ClientOptions() - self._client_options = cast(client_options_lib.ClientOptions, self._client_options) - - universe_domain_opt = getattr(self._client_options, 'universe_domain', None) - - self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = ArtifactRegistryClient._read_environment_variables() - self._client_cert_source = ArtifactRegistryClient._get_client_cert_source(self._client_options.client_cert_source, self._use_client_cert) - self._universe_domain = ArtifactRegistryClient._get_universe_domain(universe_domain_opt, self._universe_domain_env) - self._api_endpoint = None # updated below, depending on `transport` - - # Initialize the universe domain validation. - self._is_universe_domain_valid = False - - api_key_value = getattr(self._client_options, "api_key", None) - if api_key_value and credentials: - raise ValueError("client_options.api_key and credentials are mutually exclusive") - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - transport_provided = isinstance(transport, ArtifactRegistryTransport) - if transport_provided: - # transport is a ArtifactRegistryTransport instance. - if credentials or self._client_options.credentials_file or api_key_value: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if self._client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = cast(ArtifactRegistryTransport, transport) - self._api_endpoint = self._transport.host - - self._api_endpoint = (self._api_endpoint or - ArtifactRegistryClient._get_api_endpoint( - self._client_options.api_endpoint, - self._client_cert_source, - self._universe_domain, - self._use_mtls_endpoint)) - - if not transport_provided: - import google.auth._default # type: ignore - - if api_key_value and hasattr(google.auth._default, "get_api_key_credentials"): - credentials = google.auth._default.get_api_key_credentials(api_key_value) - - transport_init: Union[Type[ArtifactRegistryTransport], Callable[..., ArtifactRegistryTransport]] = ( - ArtifactRegistryClient.get_transport_class(transport) - if isinstance(transport, str) or transport is None - else cast(Callable[..., ArtifactRegistryTransport], transport) - ) - # initialize with the provided callable or the passed in class - self._transport = transport_init( - credentials=credentials, - credentials_file=self._client_options.credentials_file, - host=self._api_endpoint, - scopes=self._client_options.scopes, - client_cert_source_for_mtls=self._client_cert_source, - quota_project_id=self._client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - api_audience=self._client_options.api_audience, - ) - - def import_apt_artifacts(self, - request: Optional[Union[apt_artifact.ImportAptArtifactsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Imports Apt artifacts. The returned Operation will - complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - .. 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_v1beta2 - - def sample_import_apt_artifacts(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ImportAptArtifactsRequest( - ) - - # Make the request - operation = client.import_apt_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.ImportAptArtifactsRequest, dict]): - The request object. The request to import new apt - artifacts. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1beta2.types.ImportAptArtifactsResponse` - The response message from importing APT artifacts. - - """ - # Create or coerce a protobuf request object. - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, apt_artifact.ImportAptArtifactsRequest): - request = apt_artifact.ImportAptArtifactsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.import_apt_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - apt_artifact.ImportAptArtifactsResponse, - metadata_type=apt_artifact.ImportAptArtifactsMetadata, - ) - - # Done; return the response. - return response - - def import_yum_artifacts(self, - request: Optional[Union[yum_artifact.ImportYumArtifactsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Imports Yum (RPM) artifacts. The returned Operation - will complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - .. 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_v1beta2 - - def sample_import_yum_artifacts(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ImportYumArtifactsRequest( - ) - - # Make the request - operation = client.import_yum_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.ImportYumArtifactsRequest, dict]): - The request object. The request to import new yum - artifacts. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1beta2.types.ImportYumArtifactsResponse` - The response message from importing YUM artifacts. - - """ - # Create or coerce a protobuf request object. - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, yum_artifact.ImportYumArtifactsRequest): - request = yum_artifact.ImportYumArtifactsRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.import_yum_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - yum_artifact.ImportYumArtifactsResponse, - metadata_type=yum_artifact.ImportYumArtifactsMetadata, - ) - - # Done; return the response. - return response - - def list_repositories(self, - request: Optional[Union[repository.ListRepositoriesRequest, 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.ListRepositoriesPager: - r"""Lists repositories. - - .. 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_v1beta2 - - def sample_list_repositories(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListRepositoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_repositories(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.ListRepositoriesRequest, dict]): - The request object. The request to list repositories. - parent (str): - Required. The name of the parent - resource whose repositories 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_v1beta2.services.artifact_registry.pagers.ListRepositoriesPager: - The response from listing - repositories. - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.ListRepositoriesRequest): - request = repository.ListRepositoriesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_repositories] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListRepositoriesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_repository(self, - request: Optional[Union[repository.GetRepositoryRequest, 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]] = (), - ) -> repository.Repository: - r"""Gets a repository. - - .. 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_v1beta2 - - def sample_get_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetRepositoryRequest( - name="name_value", - ) - - # Make the request - response = client.get_repository(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.GetRepositoryRequest, dict]): - The request object. The request to retrieve a repository. - name (str): - Required. The name of the repository - to retrieve. - - 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_v1beta2.types.Repository: - A Repository for storing artifacts - with a specific format. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.GetRepositoryRequest): - request = repository.GetRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_repository(self, - request: Optional[Union[gda_repository.CreateRepositoryRequest, dict]] = None, - *, - parent: Optional[str] = None, - repository: Optional[gda_repository.Repository] = None, - repository_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Creates a repository. The returned Operation will - finish once the repository has been created. Its - response will be the created Repository. - - .. 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_v1beta2 - - def sample_create_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.CreateRepositoryRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_repository(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.CreateRepositoryRequest, dict]): - The request object. The request to create a new - repository. - parent (str): - Required. The name of the parent - resource where the repository will be - created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - repository (google.cloud.artifactregistry_v1beta2.types.Repository): - The repository to be created. - This corresponds to the ``repository`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - repository_id (str): - The repository id to use for this - repository. - - This corresponds to the ``repository_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.artifactregistry_v1beta2.types.Repository` - A Repository for storing artifacts with a specific - format. - - """ - # 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, repository, repository_id]) - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_repository.CreateRepositoryRequest): - request = gda_repository.CreateRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if repository is not None: - request.repository = repository - if repository_id is not None: - request.repository_id = repository_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - gda_repository.Repository, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_repository(self, - request: Optional[Union[gda_repository.UpdateRepositoryRequest, dict]] = None, - *, - repository: Optional[gda_repository.Repository] = 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_repository.Repository: - r"""Updates a repository. - - .. 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_v1beta2 - - def sample_update_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateRepositoryRequest( - ) - - # Make the request - response = client.update_repository(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.UpdateRepositoryRequest, dict]): - The request object. The request to update a repository. - repository (google.cloud.artifactregistry_v1beta2.types.Repository): - The repository that replaces the - resource on the server. - - This corresponds to the ``repository`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_v1beta2.types.Repository: - A Repository for storing artifacts - with a specific format. - - """ - # 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([repository, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_repository.UpdateRepositoryRequest): - request = gda_repository.UpdateRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if repository is not None: - request.repository = repository - if update_mask is not None: - 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_repository] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("repository.name", request.repository.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_repository(self, - request: Optional[Union[repository.DeleteRepositoryRequest, 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]] = (), - ) -> operation.Operation: - r"""Deletes a repository and all of its contents. The - returned Operation will finish once the repository has - been deleted. It will not have any Operation metadata - and will return a google.protobuf.Empty response. - - .. 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_v1beta2 - - def sample_delete_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteRepositoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_repository(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.DeleteRepositoryRequest, dict]): - The request object. The request to delete a repository. - name (str): - Required. The name of the repository - to delete. - - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, repository.DeleteRepositoryRequest): - request = repository.DeleteRepositoryRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_repository] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_packages(self, - request: Optional[Union[package.ListPackagesRequest, 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.ListPackagesPager: - r"""Lists 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_v1beta2 - - def sample_list_packages(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListPackagesRequest( - ) - - # Make the request - page_result = client.list_packages(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.ListPackagesRequest, dict]): - The request object. The request to list packages. - parent (str): - The name of the parent resource whose - 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_v1beta2.services.artifact_registry.pagers.ListPackagesPager: - The response from listing 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.ListPackagesRequest): - request = package.ListPackagesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListPackagesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_package(self, - request: Optional[Union[package.GetPackageRequest, 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]] = (), - ) -> package.Package: - r"""Gets a 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_v1beta2 - - def sample_get_package(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetPackageRequest( - ) - - # Make the request - response = client.get_package(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.GetPackageRequest, dict]): - The request object. The request to retrieve a package. - name (str): - The name of the package to retrieve. - 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_v1beta2.types.Package: - Packages are named collections of - versions. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.GetPackageRequest): - request = package.GetPackageRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_package(self, - request: Optional[Union[package.DeletePackageRequest, 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]] = (), - ) -> operation.Operation: - r"""Deletes a package and all of its versions and tags. - The returned operation will complete once the package - has been deleted. - - .. 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_v1beta2 - - def sample_delete_package(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeletePackageRequest( - ) - - # Make the request - operation = client.delete_package(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.DeletePackageRequest, dict]): - The request object. The request to delete a package. - name (str): - The name of the package to delete. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, package.DeletePackageRequest): - request = package.DeletePackageRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_versions(self, - request: Optional[Union[version.ListVersionsRequest, 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.ListVersionsPager: - r"""Lists versions. - - .. 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_v1beta2 - - def sample_list_versions(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListVersionsRequest( - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.ListVersionsRequest, dict]): - The request object. The request to list versions. - parent (str): - The name of the parent resource whose - versions 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_v1beta2.services.artifact_registry.pagers.ListVersionsPager: - The response from listing versions. - - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.ListVersionsRequest): - request = version.ListVersionsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_versions] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListVersionsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_version(self, - request: Optional[Union[version.GetVersionRequest, 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]] = (), - ) -> version.Version: - r"""Gets a version - - .. 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_v1beta2 - - def sample_get_version(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetVersionRequest( - ) - - # Make the request - response = client.get_version(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.GetVersionRequest, dict]): - The request object. The request to retrieve a version. - name (str): - The name of the version to retrieve. - 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_v1beta2.types.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.GetVersionRequest): - request = version.GetVersionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_version] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_version(self, - request: Optional[Union[version.DeleteVersionRequest, 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]] = (), - ) -> operation.Operation: - r"""Deletes a version and all of its content. The - returned operation will complete once the version has - been deleted. - - .. 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_v1beta2 - - def sample_delete_version(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteVersionRequest( - ) - - # Make the request - operation = client.delete_version(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.DeleteVersionRequest, dict]): - The request object. The request to delete a version. - name (str): - The name of the version to delete. - 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.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, version.DeleteVersionRequest): - request = version.DeleteVersionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_version] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - empty_pb2.Empty, - metadata_type=service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_files(self, - request: Optional[Union[file.ListFilesRequest, 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.ListFilesPager: - r"""Lists files. - - .. 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_v1beta2 - - def sample_list_files(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListFilesRequest( - ) - - # Make the request - page_result = client.list_files(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.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: - "projects/p1/locations/us-central1/repositories/repo1 - - 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_v1beta2.services.artifact_registry.pagers.ListFilesPager: - The response from listing files. - - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.ListFilesRequest): - request = file.ListFilesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_files] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListFilesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_file(self, - request: Optional[Union[file.GetFileRequest, 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]] = (), - ) -> file.File: - r"""Gets a file. - - .. 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_v1beta2 - - def sample_get_file(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetFileRequest( - ) - - # Make the request - response = client.get_file(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.GetFileRequest, dict]): - The request object. The request to retrieve a file. - name (str): - 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. - 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_v1beta2.types.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, file.GetFileRequest): - request = file.GetFileRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_file] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_tags(self, - request: Optional[Union[tag.ListTagsRequest, 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.ListTagsPager: - r"""Lists tags. - - .. 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_v1beta2 - - def sample_list_tags(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListTagsRequest( - ) - - # Make the request - page_result = client.list_tags(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.ListTagsRequest, dict]): - The request object. The request to list tags. - parent (str): - The name of the parent resource whose - tags 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_v1beta2.services.artifact_registry.pagers.ListTagsPager: - The response from listing tags. - - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.ListTagsRequest): - request = tag.ListTagsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_tags] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListTagsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_tag(self, - request: Optional[Union[tag.GetTagRequest, 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]] = (), - ) -> tag.Tag: - r"""Gets a tag. - - .. 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_v1beta2 - - def sample_get_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetTagRequest( - ) - - # Make the request - response = client.get_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.GetTagRequest, dict]): - The request object. The request to retrieve a tag. - name (str): - The name of the tag to retrieve. - 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_v1beta2.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.GetTagRequest): - request = tag.GetTagRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_tag(self, - request: Optional[Union[gda_tag.CreateTagRequest, dict]] = None, - *, - parent: Optional[str] = None, - tag: Optional[gda_tag.Tag] = None, - tag_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> gda_tag.Tag: - r"""Creates a tag. - - .. 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_v1beta2 - - def sample_create_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.CreateTagRequest( - ) - - # Make the request - response = client.create_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.CreateTagRequest, dict]): - The request object. The request to create a new tag. - parent (str): - The name of the parent resource where - the tag will be created. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag (google.cloud.artifactregistry_v1beta2.types.Tag): - The tag to be created. - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag_id (str): - The tag id to use for this - repository. - - This corresponds to the ``tag_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.cloud.artifactregistry_v1beta2.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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, tag, tag_id]) - 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_tag.CreateTagRequest): - request = gda_tag.CreateTagRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if tag is not None: - request.tag = tag - if tag_id is not None: - request.tag_id = tag_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_tag(self, - request: Optional[Union[gda_tag.UpdateTagRequest, dict]] = None, - *, - tag: Optional[gda_tag.Tag] = 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_tag.Tag: - r"""Updates a tag. - - .. 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_v1beta2 - - def sample_update_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateTagRequest( - ) - - # Make the request - response = client.update_tag(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.UpdateTagRequest, dict]): - The request object. The request to create or update a - tag. - tag (google.cloud.artifactregistry_v1beta2.types.Tag): - The tag that replaces the resource on - the server. - - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_v1beta2.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - # 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([tag, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, gda_tag.UpdateTagRequest): - request = gda_tag.UpdateTagRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if tag is not None: - request.tag = tag - if update_mask is not None: - 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_tag] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("tag.name", request.tag.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_tag(self, - request: Optional[Union[tag.DeleteTagRequest, 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]] = (), - ) -> None: - r"""Deletes a tag. - - .. 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_v1beta2 - - def sample_delete_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteTagRequest( - ) - - # Make the request - client.delete_tag(request=request) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.DeleteTagRequest, dict]): - The request object. The request to delete a tag. - name (str): - The name of the tag to delete. - 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. - """ - # 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, tag.DeleteTagRequest): - request = tag.DeleteTagRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_tag] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - def set_iam_policy(self, - request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Updates the IAM policy for a given resource. - - .. 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_v1beta2 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - def sample_set_iam_policy(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = client.set_iam_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): - The request object. Request message for ``SetIamPolicy`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). - - """ - # Create or coerce a protobuf request object. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.SetIamPolicyRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.SetIamPolicyRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_iam_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_iam_policy(self, - request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Gets the IAM policy for a given resource. - - .. 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_v1beta2 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - def sample_get_iam_policy(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = client.get_iam_policy(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): - The request object. Request message for ``GetIamPolicy`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). - - """ - # Create or coerce a protobuf request object. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.GetIamPolicyRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.GetIamPolicyRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_iam_policy] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def test_iam_permissions(self, - request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Tests if the caller has a list of permissions on a - resource. - - .. 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_v1beta2 - from google.iam.v1 import iam_policy_pb2 # type: ignore - - def sample_test_iam_permissions(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], - ) - - # Make the request - response = client.test_iam_permissions(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): - The request object. Request message for ``TestIamPermissions`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: - Response message for TestIamPermissions method. - """ - # Create or coerce a protobuf request object. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.TestIamPermissionsRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.TestIamPermissionsRequest() - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("resource", request.resource), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_project_settings(self, - request: Optional[Union[settings.GetProjectSettingsRequest, 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]] = (), - ) -> settings.ProjectSettings: - r"""Retrieves the Settings 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_v1beta2 - - def sample_get_project_settings(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetProjectSettingsRequest( - name="name_value", - ) - - # Make the request - response = client.get_project_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.GetProjectSettingsRequest, dict]): - The request object. Gets the redirection status for a - project. - name (str): - Required. The name of the - projectSettings 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_v1beta2.types.ProjectSettings: - The Artifact Registry settings 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, settings.GetProjectSettingsRequest): - request = settings.GetProjectSettingsRequest(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_project_settings] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_project_settings(self, - request: Optional[Union[settings.UpdateProjectSettingsRequest, dict]] = None, - *, - project_settings: Optional[settings.ProjectSettings] = 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]] = (), - ) -> settings.ProjectSettings: - r"""Updates the Settings 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_v1beta2 - - def sample_update_project_settings(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateProjectSettingsRequest( - ) - - # Make the request - response = client.update_project_settings(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.artifactregistry_v1beta2.types.UpdateProjectSettingsRequest, dict]): - The request object. Sets the settings of the project. - project_settings (google.cloud.artifactregistry_v1beta2.types.ProjectSettings): - The project settings. - This corresponds to the ``project_settings`` 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_v1beta2.types.ProjectSettings: - The Artifact Registry settings 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([project_settings, 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.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, settings.UpdateProjectSettingsRequest): - request = settings.UpdateProjectSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if project_settings is not None: - request.project_settings = project_settings - 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_project_settings] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("project_settings.name", request.project_settings.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "ArtifactRegistryClient": - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - self.transport.close() - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` 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: - ~.location_pb2.Location: - Location 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 = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_location] - - # 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),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_locations] - - # 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),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "ArtifactRegistryClient", -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py deleted file mode 100644 index b14b9660ded8..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py +++ /dev/null @@ -1,706 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import retry_async as retries_async -from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator, Union -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] - OptionalAsyncRetry = Union[retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore - -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import version - - -class ListRepositoriesPager: - """A pager for iterating through ``list_repositories`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListRepositoriesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``repositories`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListRepositories`` requests and continue to iterate - through the ``repositories`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListRepositoriesResponse` - 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[..., repository.ListRepositoriesResponse], - request: repository.ListRepositoriesRequest, - response: repository.ListRepositoriesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListRepositoriesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListRepositoriesResponse): - The initial response object. - 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. - """ - self._method = method - self._request = repository.ListRepositoriesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[repository.ListRepositoriesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[repository.Repository]: - for page in self.pages: - yield from page.repositories - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListRepositoriesAsyncPager: - """A pager for iterating through ``list_repositories`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListRepositoriesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``repositories`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListRepositories`` requests and continue to iterate - through the ``repositories`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListRepositoriesResponse` - 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[repository.ListRepositoriesResponse]], - request: repository.ListRepositoriesRequest, - response: repository.ListRepositoriesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListRepositoriesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListRepositoriesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = repository.ListRepositoriesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[repository.ListRepositoriesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[repository.Repository]: - async def async_generator(): - async for page in self.pages: - for response in page.repositories: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPackagesPager: - """A pager for iterating through ``list_packages`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListPackagesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``packages`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListPackages`` requests and continue to iterate - through the ``packages`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListPackagesResponse` - 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[..., package.ListPackagesResponse], - request: package.ListPackagesRequest, - response: package.ListPackagesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListPackagesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListPackagesResponse): - The initial response object. - 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. - """ - self._method = method - self._request = package.ListPackagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[package.ListPackagesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[package.Package]: - for page in self.pages: - yield from page.packages - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListPackagesAsyncPager: - """A pager for iterating through ``list_packages`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListPackagesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``packages`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListPackages`` requests and continue to iterate - through the ``packages`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListPackagesResponse` - 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[package.ListPackagesResponse]], - request: package.ListPackagesRequest, - response: package.ListPackagesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListPackagesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListPackagesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = package.ListPackagesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[package.ListPackagesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[package.Package]: - async def async_generator(): - async for page in self.pages: - for response in page.packages: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVersionsPager: - """A pager for iterating through ``list_versions`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListVersionsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``versions`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListVersions`` requests and continue to iterate - through the ``versions`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListVersionsResponse` - 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[..., version.ListVersionsResponse], - request: version.ListVersionsRequest, - response: version.ListVersionsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListVersionsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListVersionsResponse): - The initial response object. - 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. - """ - self._method = method - self._request = version.ListVersionsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[version.ListVersionsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[version.Version]: - for page in self.pages: - yield from page.versions - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVersionsAsyncPager: - """A pager for iterating through ``list_versions`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListVersionsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``versions`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListVersions`` requests and continue to iterate - through the ``versions`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListVersionsResponse` - 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[version.ListVersionsResponse]], - request: version.ListVersionsRequest, - response: version.ListVersionsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListVersionsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListVersionsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = version.ListVersionsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[version.ListVersionsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[version.Version]: - async def async_generator(): - async for page in self.pages: - for response in page.versions: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListFilesPager: - """A pager for iterating through ``list_files`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListFilesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``files`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListFiles`` requests and continue to iterate - through the ``files`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListFilesResponse` - 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[..., file.ListFilesResponse], - request: file.ListFilesRequest, - response: file.ListFilesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListFilesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListFilesResponse): - The initial response object. - 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. - """ - self._method = method - self._request = file.ListFilesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[file.ListFilesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[file.File]: - for page in self.pages: - yield from page.files - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListFilesAsyncPager: - """A pager for iterating through ``list_files`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListFilesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``files`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListFiles`` requests and continue to iterate - through the ``files`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListFilesResponse` - 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[file.ListFilesResponse]], - request: file.ListFilesRequest, - response: file.ListFilesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListFilesRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListFilesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = file.ListFilesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[file.ListFilesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[file.File]: - async def async_generator(): - async for page in self.pages: - for response in page.files: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTagsPager: - """A pager for iterating through ``list_tags`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListTagsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``tags`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListTags`` requests and continue to iterate - through the ``tags`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListTagsResponse` - 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[..., tag.ListTagsResponse], - request: tag.ListTagsRequest, - response: tag.ListTagsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListTagsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListTagsResponse): - The initial response object. - 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. - """ - self._method = method - self._request = tag.ListTagsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[tag.ListTagsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[tag.Tag]: - for page in self.pages: - yield from page.tags - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListTagsAsyncPager: - """A pager for iterating through ``list_tags`` requests. - - This class thinly wraps an initial - :class:`google.cloud.artifactregistry_v1beta2.types.ListTagsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``tags`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListTags`` requests and continue to iterate - through the ``tags`` field on the - corresponding responses. - - All the usual :class:`google.cloud.artifactregistry_v1beta2.types.ListTagsResponse` - 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[tag.ListTagsResponse]], - request: tag.ListTagsRequest, - response: tag.ListTagsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - 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_v1beta2.types.ListTagsRequest): - The initial request object. - response (google.cloud.artifactregistry_v1beta2.types.ListTagsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): 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. - """ - self._method = method - self._request = tag.ListTagsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[tag.ListTagsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[tag.Tag]: - async def async_generator(): - async for page in self.pages: - for response in page.tags: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/README.rst b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/README.rst deleted file mode 100644 index d30fbe83290d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/README.rst +++ /dev/null @@ -1,9 +0,0 @@ - -transport inheritance structure -_______________________________ - -`ArtifactRegistryTransport` is the ABC for all transports. -- public child `ArtifactRegistryGrpcTransport` for sync gRPC transport (defined in `grpc.py`). -- public child `ArtifactRegistryGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). -- private child `_BaseArtifactRegistryRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). -- public child `ArtifactRegistryRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`). diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/__init__.py deleted file mode 100644 index 819525a6bc43..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 collections import OrderedDict -from typing import Dict, Type - -from .base import ArtifactRegistryTransport -from .grpc import ArtifactRegistryGrpcTransport -from .grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport -from .rest import ArtifactRegistryRestTransport -from .rest import ArtifactRegistryRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[ArtifactRegistryTransport]] -_transport_registry['grpc'] = ArtifactRegistryGrpcTransport -_transport_registry['grpc_asyncio'] = ArtifactRegistryGrpcAsyncIOTransport -_transport_registry['rest'] = ArtifactRegistryRestTransport - -__all__ = ( - 'ArtifactRegistryTransport', - 'ArtifactRegistryGrpcTransport', - 'ArtifactRegistryGrpcAsyncIOTransport', - 'ArtifactRegistryRestTransport', - 'ArtifactRegistryRestInterceptor', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/base.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/base.py deleted file mode 100644 index 19454eae3183..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/base.py +++ /dev/null @@ -1,672 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union - -from google.cloud.artifactregistry_v1beta2 import gapic_version as package_version - -import google.auth # type: ignore -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.artifactregistry_v1beta2.types import apt_artifact -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository -from google.cloud.artifactregistry_v1beta2.types import settings -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag -from google.cloud.artifactregistry_v1beta2.types import version -from google.cloud.artifactregistry_v1beta2.types import yum_artifact -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 # type: ignore -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class ArtifactRegistryTransport(abc.ABC): - """Abstract transport class for ArtifactRegistry.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ) - - DEFAULT_HOST: str = 'artifactregistry.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - """ - - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - - # Save the scopes. - self._scopes = scopes - if not hasattr(self, "_ignore_credentials"): - self._ignore_credentials: bool = False - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) - elif credentials is None and not self._ignore_credentials: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) - # Don't apply audience if the credentials file passed from user. - if hasattr(credentials, "with_gdch_audience"): - credentials = credentials.with_gdch_audience(api_audience if api_audience else host) - - # If the credentials are service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - @property - def host(self): - return self._host - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.import_apt_artifacts: gapic_v1.method.wrap_method( - self.import_apt_artifacts, - default_timeout=None, - client_info=client_info, - ), - self.import_yum_artifacts: gapic_v1.method.wrap_method( - self.import_yum_artifacts, - default_timeout=None, - client_info=client_info, - ), - self.list_repositories: gapic_v1.method.wrap_method( - self.list_repositories, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_repository: gapic_v1.method.wrap_method( - self.get_repository, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.create_repository: gapic_v1.method.wrap_method( - self.create_repository, - default_timeout=30.0, - client_info=client_info, - ), - self.update_repository: gapic_v1.method.wrap_method( - self.update_repository, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_repository: gapic_v1.method.wrap_method( - self.delete_repository, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_packages: gapic_v1.method.wrap_method( - self.list_packages, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_package: gapic_v1.method.wrap_method( - self.get_package, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.delete_package: gapic_v1.method.wrap_method( - self.delete_package, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_versions: gapic_v1.method.wrap_method( - self.list_versions, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_version: gapic_v1.method.wrap_method( - self.get_version, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.delete_version: gapic_v1.method.wrap_method( - self.delete_version, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_files: gapic_v1.method.wrap_method( - self.list_files, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_file: gapic_v1.method.wrap_method( - self.get_file, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_tags: gapic_v1.method.wrap_method( - self.list_tags, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_tag: gapic_v1.method.wrap_method( - self.get_tag, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.create_tag: gapic_v1.method.wrap_method( - self.create_tag, - default_timeout=30.0, - client_info=client_info, - ), - self.update_tag: gapic_v1.method.wrap_method( - self.update_tag, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_tag: gapic_v1.method.wrap_method( - self.delete_tag, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, - default_timeout=None, - client_info=client_info, - ), - self.get_iam_policy: gapic_v1.method.wrap_method( - self.get_iam_policy, - default_retry=retries.Retry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.test_iam_permissions: gapic_v1.method.wrap_method( - self.test_iam_permissions, - default_timeout=30.0, - client_info=client_info, - ), - self.get_project_settings: gapic_v1.method.wrap_method( - self.get_project_settings, - default_timeout=None, - client_info=client_info, - ), - self.update_project_settings: gapic_v1.method.wrap_method( - self.update_project_settings, - default_timeout=None, - client_info=client_info, - ), - self.get_location: gapic_v1.method.wrap_method( - self.get_location, - default_timeout=None, - client_info=client_info, - ), - self.list_locations: gapic_v1.method.wrap_method( - self.list_locations, - default_timeout=None, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def operations_client(self): - """Return the client designed to process long-running operations.""" - raise NotImplementedError() - - @property - def import_apt_artifacts(self) -> Callable[ - [apt_artifact.ImportAptArtifactsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def import_yum_artifacts(self) -> Callable[ - [yum_artifact.ImportYumArtifactsRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_repositories(self) -> Callable[ - [repository.ListRepositoriesRequest], - Union[ - repository.ListRepositoriesResponse, - Awaitable[repository.ListRepositoriesResponse] - ]]: - raise NotImplementedError() - - @property - def get_repository(self) -> Callable[ - [repository.GetRepositoryRequest], - Union[ - repository.Repository, - Awaitable[repository.Repository] - ]]: - raise NotImplementedError() - - @property - def create_repository(self) -> Callable[ - [gda_repository.CreateRepositoryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_repository(self) -> Callable[ - [gda_repository.UpdateRepositoryRequest], - Union[ - gda_repository.Repository, - Awaitable[gda_repository.Repository] - ]]: - raise NotImplementedError() - - @property - def delete_repository(self) -> Callable[ - [repository.DeleteRepositoryRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_packages(self) -> Callable[ - [package.ListPackagesRequest], - Union[ - package.ListPackagesResponse, - Awaitable[package.ListPackagesResponse] - ]]: - raise NotImplementedError() - - @property - def get_package(self) -> Callable[ - [package.GetPackageRequest], - Union[ - package.Package, - Awaitable[package.Package] - ]]: - raise NotImplementedError() - - @property - def delete_package(self) -> Callable[ - [package.DeletePackageRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - Union[ - version.ListVersionsResponse, - Awaitable[version.ListVersionsResponse] - ]]: - raise NotImplementedError() - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - Union[ - version.Version, - Awaitable[version.Version] - ]]: - raise NotImplementedError() - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_files(self) -> Callable[ - [file.ListFilesRequest], - Union[ - file.ListFilesResponse, - Awaitable[file.ListFilesResponse] - ]]: - raise NotImplementedError() - - @property - def get_file(self) -> Callable[ - [file.GetFileRequest], - Union[ - file.File, - Awaitable[file.File] - ]]: - raise NotImplementedError() - - @property - def list_tags(self) -> Callable[ - [tag.ListTagsRequest], - Union[ - tag.ListTagsResponse, - Awaitable[tag.ListTagsResponse] - ]]: - raise NotImplementedError() - - @property - def get_tag(self) -> Callable[ - [tag.GetTagRequest], - Union[ - tag.Tag, - Awaitable[tag.Tag] - ]]: - raise NotImplementedError() - - @property - def create_tag(self) -> Callable[ - [gda_tag.CreateTagRequest], - Union[ - gda_tag.Tag, - Awaitable[gda_tag.Tag] - ]]: - raise NotImplementedError() - - @property - def update_tag(self) -> Callable[ - [gda_tag.UpdateTagRequest], - Union[ - gda_tag.Tag, - Awaitable[gda_tag.Tag] - ]]: - raise NotImplementedError() - - @property - def delete_tag(self) -> Callable[ - [tag.DeleteTagRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def set_iam_policy(self) -> Callable[ - [iam_policy_pb2.SetIamPolicyRequest], - Union[ - policy_pb2.Policy, - Awaitable[policy_pb2.Policy] - ]]: - raise NotImplementedError() - - @property - def get_iam_policy(self) -> Callable[ - [iam_policy_pb2.GetIamPolicyRequest], - Union[ - policy_pb2.Policy, - Awaitable[policy_pb2.Policy] - ]]: - raise NotImplementedError() - - @property - def test_iam_permissions(self) -> Callable[ - [iam_policy_pb2.TestIamPermissionsRequest], - Union[ - iam_policy_pb2.TestIamPermissionsResponse, - Awaitable[iam_policy_pb2.TestIamPermissionsResponse] - ]]: - raise NotImplementedError() - - @property - def get_project_settings(self) -> Callable[ - [settings.GetProjectSettingsRequest], - Union[ - settings.ProjectSettings, - Awaitable[settings.ProjectSettings] - ]]: - raise NotImplementedError() - - @property - def update_project_settings(self) -> Callable[ - [settings.UpdateProjectSettingsRequest], - Union[ - settings.ProjectSettings, - Awaitable[settings.ProjectSettings] - ]]: - raise NotImplementedError() - - @property - def get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'ArtifactRegistryTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py deleted file mode 100644 index 86a1d2b2da1e..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py +++ /dev/null @@ -1,992 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.artifactregistry_v1beta2.types import apt_artifact -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository -from google.cloud.artifactregistry_v1beta2.types import settings -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag -from google.cloud.artifactregistry_v1beta2.types import version -from google.cloud.artifactregistry_v1beta2.types import yum_artifact -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 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO - - -class ArtifactRegistryGrpcTransport(ArtifactRegistryTransport): - """gRPC backend transport for ArtifactRegistry. - - The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - _stubs: Dict[str, Callable] - - def __init__(self, *, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if a ``channel`` instance is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if a ``channel`` instance is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if a ``channel`` instance is provided. - channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): - A ``Channel`` instance through which to make calls, or a Callable - that constructs and returns one. If set to None, ``self.create_channel`` - is used to create the channel. If a Callable is given, it will be called - with the same arguments as used in ``self.create_channel``. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if a ``channel`` instance is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client: Optional[operations_v1.OperationsClient] = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if isinstance(channel, grpc.Channel): - # Ignore credentials if a channel was passed. - credentials = None - self._ignore_credentials = True - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - # initialize with the provided callable or the default channel - channel_init = channel or type(self).create_channel - self._grpc_channel = channel_init( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def import_apt_artifacts(self) -> Callable[ - [apt_artifact.ImportAptArtifactsRequest], - operations_pb2.Operation]: - r"""Return a callable for the import apt artifacts method over gRPC. - - Imports Apt artifacts. The returned Operation will - complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - Returns: - Callable[[~.ImportAptArtifactsRequest], - ~.Operation]: - 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 'import_apt_artifacts' not in self._stubs: - self._stubs['import_apt_artifacts'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportAptArtifacts', - request_serializer=apt_artifact.ImportAptArtifactsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_apt_artifacts'] - - @property - def import_yum_artifacts(self) -> Callable[ - [yum_artifact.ImportYumArtifactsRequest], - operations_pb2.Operation]: - r"""Return a callable for the import yum artifacts method over gRPC. - - Imports Yum (RPM) artifacts. The returned Operation - will complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - Returns: - Callable[[~.ImportYumArtifactsRequest], - ~.Operation]: - 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 'import_yum_artifacts' not in self._stubs: - self._stubs['import_yum_artifacts'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportYumArtifacts', - request_serializer=yum_artifact.ImportYumArtifactsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_yum_artifacts'] - - @property - def list_repositories(self) -> Callable[ - [repository.ListRepositoriesRequest], - repository.ListRepositoriesResponse]: - r"""Return a callable for the list repositories method over gRPC. - - Lists repositories. - - Returns: - Callable[[~.ListRepositoriesRequest], - ~.ListRepositoriesResponse]: - 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_repositories' not in self._stubs: - self._stubs['list_repositories'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListRepositories', - request_serializer=repository.ListRepositoriesRequest.serialize, - response_deserializer=repository.ListRepositoriesResponse.deserialize, - ) - return self._stubs['list_repositories'] - - @property - def get_repository(self) -> Callable[ - [repository.GetRepositoryRequest], - repository.Repository]: - r"""Return a callable for the get repository method over gRPC. - - Gets a repository. - - Returns: - Callable[[~.GetRepositoryRequest], - ~.Repository]: - 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_repository' not in self._stubs: - self._stubs['get_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetRepository', - request_serializer=repository.GetRepositoryRequest.serialize, - response_deserializer=repository.Repository.deserialize, - ) - return self._stubs['get_repository'] - - @property - def create_repository(self) -> Callable[ - [gda_repository.CreateRepositoryRequest], - operations_pb2.Operation]: - r"""Return a callable for the create repository method over gRPC. - - Creates a repository. The returned Operation will - finish once the repository has been created. Its - response will be the created Repository. - - Returns: - Callable[[~.CreateRepositoryRequest], - ~.Operation]: - 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 'create_repository' not in self._stubs: - self._stubs['create_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateRepository', - request_serializer=gda_repository.CreateRepositoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_repository'] - - @property - def update_repository(self) -> Callable[ - [gda_repository.UpdateRepositoryRequest], - gda_repository.Repository]: - r"""Return a callable for the update repository method over gRPC. - - Updates a repository. - - Returns: - Callable[[~.UpdateRepositoryRequest], - ~.Repository]: - 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_repository' not in self._stubs: - self._stubs['update_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateRepository', - request_serializer=gda_repository.UpdateRepositoryRequest.serialize, - response_deserializer=gda_repository.Repository.deserialize, - ) - return self._stubs['update_repository'] - - @property - def delete_repository(self) -> Callable[ - [repository.DeleteRepositoryRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete repository method over gRPC. - - Deletes a repository and all of its contents. The - returned Operation will finish once the repository has - been deleted. It will not have any Operation metadata - and will return a google.protobuf.Empty response. - - Returns: - Callable[[~.DeleteRepositoryRequest], - ~.Operation]: - 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 'delete_repository' not in self._stubs: - self._stubs['delete_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteRepository', - request_serializer=repository.DeleteRepositoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_repository'] - - @property - def list_packages(self) -> Callable[ - [package.ListPackagesRequest], - package.ListPackagesResponse]: - r"""Return a callable for the list packages method over gRPC. - - Lists packages. - - Returns: - Callable[[~.ListPackagesRequest], - ~.ListPackagesResponse]: - 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_packages' not in self._stubs: - self._stubs['list_packages'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListPackages', - request_serializer=package.ListPackagesRequest.serialize, - response_deserializer=package.ListPackagesResponse.deserialize, - ) - return self._stubs['list_packages'] - - @property - def get_package(self) -> Callable[ - [package.GetPackageRequest], - package.Package]: - r"""Return a callable for the get package method over gRPC. - - Gets a package. - - Returns: - Callable[[~.GetPackageRequest], - ~.Package]: - 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_package' not in self._stubs: - self._stubs['get_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetPackage', - request_serializer=package.GetPackageRequest.serialize, - response_deserializer=package.Package.deserialize, - ) - return self._stubs['get_package'] - - @property - def delete_package(self) -> Callable[ - [package.DeletePackageRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete package method over gRPC. - - Deletes a package and all of its versions and tags. - The returned operation will complete once the package - has been deleted. - - Returns: - Callable[[~.DeletePackageRequest], - ~.Operation]: - 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 'delete_package' not in self._stubs: - self._stubs['delete_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeletePackage', - request_serializer=package.DeletePackageRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_package'] - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - version.ListVersionsResponse]: - r"""Return a callable for the list versions method over gRPC. - - Lists versions. - - Returns: - Callable[[~.ListVersionsRequest], - ~.ListVersionsResponse]: - 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_versions' not in self._stubs: - self._stubs['list_versions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListVersions', - request_serializer=version.ListVersionsRequest.serialize, - response_deserializer=version.ListVersionsResponse.deserialize, - ) - return self._stubs['list_versions'] - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - version.Version]: - r"""Return a callable for the get version method over gRPC. - - Gets a version - - Returns: - Callable[[~.GetVersionRequest], - ~.Version]: - 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_version' not in self._stubs: - self._stubs['get_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetVersion', - request_serializer=version.GetVersionRequest.serialize, - response_deserializer=version.Version.deserialize, - ) - return self._stubs['get_version'] - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete version method over gRPC. - - Deletes a version and all of its content. The - returned operation will complete once the version has - been deleted. - - Returns: - Callable[[~.DeleteVersionRequest], - ~.Operation]: - 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 'delete_version' not in self._stubs: - self._stubs['delete_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteVersion', - request_serializer=version.DeleteVersionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_version'] - - @property - def list_files(self) -> Callable[ - [file.ListFilesRequest], - file.ListFilesResponse]: - r"""Return a callable for the list files method over gRPC. - - Lists files. - - Returns: - Callable[[~.ListFilesRequest], - ~.ListFilesResponse]: - 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_files' not in self._stubs: - self._stubs['list_files'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListFiles', - request_serializer=file.ListFilesRequest.serialize, - response_deserializer=file.ListFilesResponse.deserialize, - ) - return self._stubs['list_files'] - - @property - def get_file(self) -> Callable[ - [file.GetFileRequest], - file.File]: - r"""Return a callable for the get file method over gRPC. - - Gets a file. - - Returns: - Callable[[~.GetFileRequest], - ~.File]: - 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_file' not in self._stubs: - self._stubs['get_file'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetFile', - request_serializer=file.GetFileRequest.serialize, - response_deserializer=file.File.deserialize, - ) - return self._stubs['get_file'] - - @property - def list_tags(self) -> Callable[ - [tag.ListTagsRequest], - tag.ListTagsResponse]: - r"""Return a callable for the list tags method over gRPC. - - Lists tags. - - Returns: - Callable[[~.ListTagsRequest], - ~.ListTagsResponse]: - 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_tags' not in self._stubs: - self._stubs['list_tags'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListTags', - request_serializer=tag.ListTagsRequest.serialize, - response_deserializer=tag.ListTagsResponse.deserialize, - ) - return self._stubs['list_tags'] - - @property - def get_tag(self) -> Callable[ - [tag.GetTagRequest], - tag.Tag]: - r"""Return a callable for the get tag method over gRPC. - - Gets a tag. - - Returns: - Callable[[~.GetTagRequest], - ~.Tag]: - 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_tag' not in self._stubs: - self._stubs['get_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetTag', - request_serializer=tag.GetTagRequest.serialize, - response_deserializer=tag.Tag.deserialize, - ) - return self._stubs['get_tag'] - - @property - def create_tag(self) -> Callable[ - [gda_tag.CreateTagRequest], - gda_tag.Tag]: - r"""Return a callable for the create tag method over gRPC. - - Creates a tag. - - Returns: - Callable[[~.CreateTagRequest], - ~.Tag]: - 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 'create_tag' not in self._stubs: - self._stubs['create_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateTag', - request_serializer=gda_tag.CreateTagRequest.serialize, - response_deserializer=gda_tag.Tag.deserialize, - ) - return self._stubs['create_tag'] - - @property - def update_tag(self) -> Callable[ - [gda_tag.UpdateTagRequest], - gda_tag.Tag]: - r"""Return a callable for the update tag method over gRPC. - - Updates a tag. - - Returns: - Callable[[~.UpdateTagRequest], - ~.Tag]: - 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_tag' not in self._stubs: - self._stubs['update_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateTag', - request_serializer=gda_tag.UpdateTagRequest.serialize, - response_deserializer=gda_tag.Tag.deserialize, - ) - return self._stubs['update_tag'] - - @property - def delete_tag(self) -> Callable[ - [tag.DeleteTagRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete tag method over gRPC. - - Deletes a tag. - - Returns: - Callable[[~.DeleteTagRequest], - ~.Empty]: - 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 'delete_tag' not in self._stubs: - self._stubs['delete_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteTag', - request_serializer=tag.DeleteTagRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_tag'] - - @property - def set_iam_policy(self) -> Callable[ - [iam_policy_pb2.SetIamPolicyRequest], - policy_pb2.Policy]: - r"""Return a callable for the set iam policy method over gRPC. - - Updates the IAM policy for a given resource. - - Returns: - Callable[[~.SetIamPolicyRequest], - ~.Policy]: - 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 'set_iam_policy' not in self._stubs: - self._stubs['set_iam_policy'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/SetIamPolicy', - request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, - response_deserializer=policy_pb2.Policy.FromString, - ) - return self._stubs['set_iam_policy'] - - @property - def get_iam_policy(self) -> Callable[ - [iam_policy_pb2.GetIamPolicyRequest], - policy_pb2.Policy]: - r"""Return a callable for the get iam policy method over gRPC. - - Gets the IAM policy for a given resource. - - Returns: - Callable[[~.GetIamPolicyRequest], - ~.Policy]: - 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_iam_policy' not in self._stubs: - self._stubs['get_iam_policy'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetIamPolicy', - request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, - response_deserializer=policy_pb2.Policy.FromString, - ) - return self._stubs['get_iam_policy'] - - @property - def test_iam_permissions(self) -> Callable[ - [iam_policy_pb2.TestIamPermissionsRequest], - iam_policy_pb2.TestIamPermissionsResponse]: - r"""Return a callable for the test iam permissions method over gRPC. - - Tests if the caller has a list of permissions on a - resource. - - Returns: - Callable[[~.TestIamPermissionsRequest], - ~.TestIamPermissionsResponse]: - 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 'test_iam_permissions' not in self._stubs: - self._stubs['test_iam_permissions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/TestIamPermissions', - request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, - response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, - ) - return self._stubs['test_iam_permissions'] - - @property - def get_project_settings(self) -> Callable[ - [settings.GetProjectSettingsRequest], - settings.ProjectSettings]: - r"""Return a callable for the get project settings method over gRPC. - - Retrieves the Settings for the Project. - - Returns: - Callable[[~.GetProjectSettingsRequest], - ~.ProjectSettings]: - 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_project_settings' not in self._stubs: - self._stubs['get_project_settings'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetProjectSettings', - request_serializer=settings.GetProjectSettingsRequest.serialize, - response_deserializer=settings.ProjectSettings.deserialize, - ) - return self._stubs['get_project_settings'] - - @property - def update_project_settings(self) -> Callable[ - [settings.UpdateProjectSettingsRequest], - settings.ProjectSettings]: - r"""Return a callable for the update project settings method over gRPC. - - Updates the Settings for the Project. - - Returns: - Callable[[~.UpdateProjectSettingsRequest], - ~.ProjectSettings]: - 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_project_settings' not in self._stubs: - self._stubs['update_project_settings'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateProjectSettings', - request_serializer=settings.UpdateProjectSettingsRequest.serialize, - response_deserializer=settings.ProjectSettings.deserialize, - ) - return self._stubs['update_project_settings'] - - def close(self): - self.grpc_channel.close() - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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 "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'ArtifactRegistryGrpcTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py deleted file mode 100644 index 4e8db69b9739..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py +++ /dev/null @@ -1,1278 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import inspect -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import exceptions as core_exceptions -from google.api_core import retry_async as retries -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.artifactregistry_v1beta2.types import apt_artifact -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository -from google.cloud.artifactregistry_v1beta2.types import settings -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag -from google.cloud.artifactregistry_v1beta2.types import version -from google.cloud.artifactregistry_v1beta2.types import yum_artifact -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 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO -from .grpc import ArtifactRegistryGrpcTransport - - -class ArtifactRegistryGrpcAsyncIOTransport(ArtifactRegistryTransport): - """gRPC AsyncIO backend transport for ArtifactRegistry. - - The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel(cls, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - def __init__(self, *, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if a ``channel`` instance is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if a ``channel`` instance is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]): - A ``Channel`` instance through which to make calls, or a Callable - that constructs and returns one. If set to None, ``self.create_channel`` - is used to create the channel. If a Callable is given, it will be called - with the same arguments as used in ``self.create_channel``. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if a ``channel`` instance is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if isinstance(channel, aio.Channel): - # Ignore credentials if a channel was passed. - credentials = None - self._ignore_credentials = True - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - # initialize with the provided callable or the default channel - channel_init = channel or type(self).create_channel - self._grpc_channel = channel_init( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._wrap_with_kind = "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def operations_client(self) -> operations_v1.OperationsAsyncClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Quick check: Only create a new client if we do not already have one. - if self._operations_client is None: - self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def import_apt_artifacts(self) -> Callable[ - [apt_artifact.ImportAptArtifactsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the import apt artifacts method over gRPC. - - Imports Apt artifacts. The returned Operation will - complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - Returns: - Callable[[~.ImportAptArtifactsRequest], - Awaitable[~.Operation]]: - 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 'import_apt_artifacts' not in self._stubs: - self._stubs['import_apt_artifacts'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportAptArtifacts', - request_serializer=apt_artifact.ImportAptArtifactsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_apt_artifacts'] - - @property - def import_yum_artifacts(self) -> Callable[ - [yum_artifact.ImportYumArtifactsRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the import yum artifacts method over gRPC. - - Imports Yum (RPM) artifacts. The returned Operation - will complete once the resources are imported. Package, - Version, and File resources are created based on the - imported artifacts. Imported artifacts that conflict - with existing resources are ignored. - - Returns: - Callable[[~.ImportYumArtifactsRequest], - Awaitable[~.Operation]]: - 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 'import_yum_artifacts' not in self._stubs: - self._stubs['import_yum_artifacts'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportYumArtifacts', - request_serializer=yum_artifact.ImportYumArtifactsRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['import_yum_artifacts'] - - @property - def list_repositories(self) -> Callable[ - [repository.ListRepositoriesRequest], - Awaitable[repository.ListRepositoriesResponse]]: - r"""Return a callable for the list repositories method over gRPC. - - Lists repositories. - - Returns: - Callable[[~.ListRepositoriesRequest], - Awaitable[~.ListRepositoriesResponse]]: - 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_repositories' not in self._stubs: - self._stubs['list_repositories'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListRepositories', - request_serializer=repository.ListRepositoriesRequest.serialize, - response_deserializer=repository.ListRepositoriesResponse.deserialize, - ) - return self._stubs['list_repositories'] - - @property - def get_repository(self) -> Callable[ - [repository.GetRepositoryRequest], - Awaitable[repository.Repository]]: - r"""Return a callable for the get repository method over gRPC. - - Gets a repository. - - Returns: - Callable[[~.GetRepositoryRequest], - Awaitable[~.Repository]]: - 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_repository' not in self._stubs: - self._stubs['get_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetRepository', - request_serializer=repository.GetRepositoryRequest.serialize, - response_deserializer=repository.Repository.deserialize, - ) - return self._stubs['get_repository'] - - @property - def create_repository(self) -> Callable[ - [gda_repository.CreateRepositoryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create repository method over gRPC. - - Creates a repository. The returned Operation will - finish once the repository has been created. Its - response will be the created Repository. - - Returns: - Callable[[~.CreateRepositoryRequest], - Awaitable[~.Operation]]: - 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 'create_repository' not in self._stubs: - self._stubs['create_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateRepository', - request_serializer=gda_repository.CreateRepositoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_repository'] - - @property - def update_repository(self) -> Callable[ - [gda_repository.UpdateRepositoryRequest], - Awaitable[gda_repository.Repository]]: - r"""Return a callable for the update repository method over gRPC. - - Updates a repository. - - Returns: - Callable[[~.UpdateRepositoryRequest], - Awaitable[~.Repository]]: - 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_repository' not in self._stubs: - self._stubs['update_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateRepository', - request_serializer=gda_repository.UpdateRepositoryRequest.serialize, - response_deserializer=gda_repository.Repository.deserialize, - ) - return self._stubs['update_repository'] - - @property - def delete_repository(self) -> Callable[ - [repository.DeleteRepositoryRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete repository method over gRPC. - - Deletes a repository and all of its contents. The - returned Operation will finish once the repository has - been deleted. It will not have any Operation metadata - and will return a google.protobuf.Empty response. - - Returns: - Callable[[~.DeleteRepositoryRequest], - Awaitable[~.Operation]]: - 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 'delete_repository' not in self._stubs: - self._stubs['delete_repository'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteRepository', - request_serializer=repository.DeleteRepositoryRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_repository'] - - @property - def list_packages(self) -> Callable[ - [package.ListPackagesRequest], - Awaitable[package.ListPackagesResponse]]: - r"""Return a callable for the list packages method over gRPC. - - Lists packages. - - Returns: - Callable[[~.ListPackagesRequest], - Awaitable[~.ListPackagesResponse]]: - 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_packages' not in self._stubs: - self._stubs['list_packages'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListPackages', - request_serializer=package.ListPackagesRequest.serialize, - response_deserializer=package.ListPackagesResponse.deserialize, - ) - return self._stubs['list_packages'] - - @property - def get_package(self) -> Callable[ - [package.GetPackageRequest], - Awaitable[package.Package]]: - r"""Return a callable for the get package method over gRPC. - - Gets a package. - - Returns: - Callable[[~.GetPackageRequest], - Awaitable[~.Package]]: - 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_package' not in self._stubs: - self._stubs['get_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetPackage', - request_serializer=package.GetPackageRequest.serialize, - response_deserializer=package.Package.deserialize, - ) - return self._stubs['get_package'] - - @property - def delete_package(self) -> Callable[ - [package.DeletePackageRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete package method over gRPC. - - Deletes a package and all of its versions and tags. - The returned operation will complete once the package - has been deleted. - - Returns: - Callable[[~.DeletePackageRequest], - Awaitable[~.Operation]]: - 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 'delete_package' not in self._stubs: - self._stubs['delete_package'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeletePackage', - request_serializer=package.DeletePackageRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_package'] - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - Awaitable[version.ListVersionsResponse]]: - r"""Return a callable for the list versions method over gRPC. - - Lists versions. - - Returns: - Callable[[~.ListVersionsRequest], - Awaitable[~.ListVersionsResponse]]: - 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_versions' not in self._stubs: - self._stubs['list_versions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListVersions', - request_serializer=version.ListVersionsRequest.serialize, - response_deserializer=version.ListVersionsResponse.deserialize, - ) - return self._stubs['list_versions'] - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - Awaitable[version.Version]]: - r"""Return a callable for the get version method over gRPC. - - Gets a version - - Returns: - Callable[[~.GetVersionRequest], - Awaitable[~.Version]]: - 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_version' not in self._stubs: - self._stubs['get_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetVersion', - request_serializer=version.GetVersionRequest.serialize, - response_deserializer=version.Version.deserialize, - ) - return self._stubs['get_version'] - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete version method over gRPC. - - Deletes a version and all of its content. The - returned operation will complete once the version has - been deleted. - - Returns: - Callable[[~.DeleteVersionRequest], - Awaitable[~.Operation]]: - 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 'delete_version' not in self._stubs: - self._stubs['delete_version'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteVersion', - request_serializer=version.DeleteVersionRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_version'] - - @property - def list_files(self) -> Callable[ - [file.ListFilesRequest], - Awaitable[file.ListFilesResponse]]: - r"""Return a callable for the list files method over gRPC. - - Lists files. - - Returns: - Callable[[~.ListFilesRequest], - Awaitable[~.ListFilesResponse]]: - 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_files' not in self._stubs: - self._stubs['list_files'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListFiles', - request_serializer=file.ListFilesRequest.serialize, - response_deserializer=file.ListFilesResponse.deserialize, - ) - return self._stubs['list_files'] - - @property - def get_file(self) -> Callable[ - [file.GetFileRequest], - Awaitable[file.File]]: - r"""Return a callable for the get file method over gRPC. - - Gets a file. - - Returns: - Callable[[~.GetFileRequest], - Awaitable[~.File]]: - 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_file' not in self._stubs: - self._stubs['get_file'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetFile', - request_serializer=file.GetFileRequest.serialize, - response_deserializer=file.File.deserialize, - ) - return self._stubs['get_file'] - - @property - def list_tags(self) -> Callable[ - [tag.ListTagsRequest], - Awaitable[tag.ListTagsResponse]]: - r"""Return a callable for the list tags method over gRPC. - - Lists tags. - - Returns: - Callable[[~.ListTagsRequest], - Awaitable[~.ListTagsResponse]]: - 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_tags' not in self._stubs: - self._stubs['list_tags'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListTags', - request_serializer=tag.ListTagsRequest.serialize, - response_deserializer=tag.ListTagsResponse.deserialize, - ) - return self._stubs['list_tags'] - - @property - def get_tag(self) -> Callable[ - [tag.GetTagRequest], - Awaitable[tag.Tag]]: - r"""Return a callable for the get tag method over gRPC. - - Gets a tag. - - Returns: - Callable[[~.GetTagRequest], - Awaitable[~.Tag]]: - 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_tag' not in self._stubs: - self._stubs['get_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetTag', - request_serializer=tag.GetTagRequest.serialize, - response_deserializer=tag.Tag.deserialize, - ) - return self._stubs['get_tag'] - - @property - def create_tag(self) -> Callable[ - [gda_tag.CreateTagRequest], - Awaitable[gda_tag.Tag]]: - r"""Return a callable for the create tag method over gRPC. - - Creates a tag. - - Returns: - Callable[[~.CreateTagRequest], - Awaitable[~.Tag]]: - 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 'create_tag' not in self._stubs: - self._stubs['create_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateTag', - request_serializer=gda_tag.CreateTagRequest.serialize, - response_deserializer=gda_tag.Tag.deserialize, - ) - return self._stubs['create_tag'] - - @property - def update_tag(self) -> Callable[ - [gda_tag.UpdateTagRequest], - Awaitable[gda_tag.Tag]]: - r"""Return a callable for the update tag method over gRPC. - - Updates a tag. - - Returns: - Callable[[~.UpdateTagRequest], - Awaitable[~.Tag]]: - 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_tag' not in self._stubs: - self._stubs['update_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateTag', - request_serializer=gda_tag.UpdateTagRequest.serialize, - response_deserializer=gda_tag.Tag.deserialize, - ) - return self._stubs['update_tag'] - - @property - def delete_tag(self) -> Callable[ - [tag.DeleteTagRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete tag method over gRPC. - - Deletes a tag. - - Returns: - Callable[[~.DeleteTagRequest], - Awaitable[~.Empty]]: - 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 'delete_tag' not in self._stubs: - self._stubs['delete_tag'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteTag', - request_serializer=tag.DeleteTagRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_tag'] - - @property - def set_iam_policy(self) -> Callable[ - [iam_policy_pb2.SetIamPolicyRequest], - Awaitable[policy_pb2.Policy]]: - r"""Return a callable for the set iam policy method over gRPC. - - Updates the IAM policy for a given resource. - - Returns: - Callable[[~.SetIamPolicyRequest], - Awaitable[~.Policy]]: - 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 'set_iam_policy' not in self._stubs: - self._stubs['set_iam_policy'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/SetIamPolicy', - request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, - response_deserializer=policy_pb2.Policy.FromString, - ) - return self._stubs['set_iam_policy'] - - @property - def get_iam_policy(self) -> Callable[ - [iam_policy_pb2.GetIamPolicyRequest], - Awaitable[policy_pb2.Policy]]: - r"""Return a callable for the get iam policy method over gRPC. - - Gets the IAM policy for a given resource. - - Returns: - Callable[[~.GetIamPolicyRequest], - Awaitable[~.Policy]]: - 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_iam_policy' not in self._stubs: - self._stubs['get_iam_policy'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetIamPolicy', - request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, - response_deserializer=policy_pb2.Policy.FromString, - ) - return self._stubs['get_iam_policy'] - - @property - def test_iam_permissions(self) -> Callable[ - [iam_policy_pb2.TestIamPermissionsRequest], - Awaitable[iam_policy_pb2.TestIamPermissionsResponse]]: - r"""Return a callable for the test iam permissions method over gRPC. - - Tests if the caller has a list of permissions on a - resource. - - Returns: - Callable[[~.TestIamPermissionsRequest], - Awaitable[~.TestIamPermissionsResponse]]: - 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 'test_iam_permissions' not in self._stubs: - self._stubs['test_iam_permissions'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/TestIamPermissions', - request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, - response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, - ) - return self._stubs['test_iam_permissions'] - - @property - def get_project_settings(self) -> Callable[ - [settings.GetProjectSettingsRequest], - Awaitable[settings.ProjectSettings]]: - r"""Return a callable for the get project settings method over gRPC. - - Retrieves the Settings for the Project. - - Returns: - Callable[[~.GetProjectSettingsRequest], - Awaitable[~.ProjectSettings]]: - 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_project_settings' not in self._stubs: - self._stubs['get_project_settings'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetProjectSettings', - request_serializer=settings.GetProjectSettingsRequest.serialize, - response_deserializer=settings.ProjectSettings.deserialize, - ) - return self._stubs['get_project_settings'] - - @property - def update_project_settings(self) -> Callable[ - [settings.UpdateProjectSettingsRequest], - Awaitable[settings.ProjectSettings]]: - r"""Return a callable for the update project settings method over gRPC. - - Updates the Settings for the Project. - - Returns: - Callable[[~.UpdateProjectSettingsRequest], - Awaitable[~.ProjectSettings]]: - 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_project_settings' not in self._stubs: - self._stubs['update_project_settings'] = self.grpc_channel.unary_unary( - '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateProjectSettings', - request_serializer=settings.UpdateProjectSettingsRequest.serialize, - response_deserializer=settings.ProjectSettings.deserialize, - ) - return self._stubs['update_project_settings'] - - def _prep_wrapped_messages(self, client_info): - """ Precompute the wrapped methods, overriding the base class method to use async wrappers.""" - self._wrapped_methods = { - self.import_apt_artifacts: self._wrap_method( - self.import_apt_artifacts, - default_timeout=None, - client_info=client_info, - ), - self.import_yum_artifacts: self._wrap_method( - self.import_yum_artifacts, - default_timeout=None, - client_info=client_info, - ), - self.list_repositories: self._wrap_method( - self.list_repositories, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_repository: self._wrap_method( - self.get_repository, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.create_repository: self._wrap_method( - self.create_repository, - default_timeout=30.0, - client_info=client_info, - ), - self.update_repository: self._wrap_method( - self.update_repository, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_repository: self._wrap_method( - self.delete_repository, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_packages: self._wrap_method( - self.list_packages, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_package: self._wrap_method( - self.get_package, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.delete_package: self._wrap_method( - self.delete_package, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_versions: self._wrap_method( - self.list_versions, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_version: self._wrap_method( - self.get_version, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.delete_version: self._wrap_method( - self.delete_version, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_files: self._wrap_method( - self.list_files, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_file: self._wrap_method( - self.get_file, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.list_tags: self._wrap_method( - self.list_tags, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.get_tag: self._wrap_method( - self.get_tag, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.create_tag: self._wrap_method( - self.create_tag, - default_timeout=30.0, - client_info=client_info, - ), - self.update_tag: self._wrap_method( - self.update_tag, - default_timeout=30.0, - client_info=client_info, - ), - self.delete_tag: self._wrap_method( - self.delete_tag, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.set_iam_policy: self._wrap_method( - self.set_iam_policy, - default_timeout=None, - client_info=client_info, - ), - self.get_iam_policy: self._wrap_method( - self.get_iam_policy, - default_retry=retries.AsyncRetry( - initial=0.1, - maximum=60.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=30.0, - ), - default_timeout=30.0, - client_info=client_info, - ), - self.test_iam_permissions: self._wrap_method( - self.test_iam_permissions, - default_timeout=30.0, - client_info=client_info, - ), - self.get_project_settings: self._wrap_method( - self.get_project_settings, - default_timeout=None, - client_info=client_info, - ), - self.update_project_settings: self._wrap_method( - self.update_project_settings, - default_timeout=None, - client_info=client_info, - ), - self.get_location: self._wrap_method( - self.get_location, - default_timeout=None, - client_info=client_info, - ), - self.list_locations: self._wrap_method( - self.list_locations, - default_timeout=None, - client_info=client_info, - ), - } - - def _wrap_method(self, func, *args, **kwargs): - if self._wrap_with_kind: # pragma: NO COVER - kwargs["kind"] = self.kind - return gapic_v1.method_async.wrap_method(func, *args, **kwargs) - - def close(self): - return self.grpc_channel.close() - - @property - def kind(self) -> str: - return "grpc_asyncio" - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations 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 "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'ArtifactRegistryGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest.py deleted file mode 100644 index 28307f9d7eca..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest.py +++ /dev/null @@ -1,3207 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 google.auth.transport.requests import AuthorizedSession # type: ignore -import json # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.api_core import exceptions as core_exceptions -from google.api_core import retry as retries -from google.api_core import rest_helpers -from google.api_core import rest_streaming -from google.api_core import gapic_v1 - -from google.protobuf import json_format -from google.api_core import operations_v1 -from google.cloud.location import locations_pb2 # type: ignore - -from requests import __version__ as requests_version -import dataclasses -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -import warnings - - -from google.cloud.artifactregistry_v1beta2.types import apt_artifact -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository -from google.cloud.artifactregistry_v1beta2.types import settings -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag -from google.cloud.artifactregistry_v1beta2.types import version -from google.cloud.artifactregistry_v1beta2.types import yum_artifact -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.longrunning import operations_pb2 # type: ignore - - -from .rest_base import _BaseArtifactRegistryRestTransport -from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, - grpc_version=None, - rest_version=f"requests@{requests_version}", -) - - -class ArtifactRegistryRestInterceptor: - """Interceptor for ArtifactRegistry. - - Interceptors are used to manipulate requests, request metadata, and responses - in arbitrary ways. - Example use cases include: - * Logging - * Verifying requests according to service or custom semantics - * Stripping extraneous information from responses - - These use cases and more can be enabled by injecting an - instance of a custom subclass when constructing the ArtifactRegistryRestTransport. - - .. code-block:: python - class MyCustomArtifactRegistryInterceptor(ArtifactRegistryRestInterceptor): - def pre_create_repository(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_repository(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_tag(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_tag(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_package(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_package(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_repository(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_repository(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_tag(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_delete_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_version(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_file(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_file(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_iam_policy(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_iam_policy(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_package(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_package(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_project_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_project_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_repository(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_repository(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_tag(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_tag(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_version(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_version(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_import_apt_artifacts(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_import_apt_artifacts(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_import_yum_artifacts(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_import_yum_artifacts(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_files(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_files(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_packages(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_packages(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_repositories(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_repositories(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_tags(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_tags(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_versions(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_versions(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_set_iam_policy(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_set_iam_policy(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_test_iam_permissions(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_test_iam_permissions(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_project_settings(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_project_settings(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_repository(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_repository(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_tag(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_tag(self, response): - logging.log(f"Received response: {response}") - return response - - transport = ArtifactRegistryRestTransport(interceptor=MyCustomArtifactRegistryInterceptor()) - client = ArtifactRegistryClient(transport=transport) - - - """ - def pre_create_repository(self, request: gda_repository.CreateRepositoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_repository.CreateRepositoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_repository - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_create_repository(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_repository - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_create_tag(self, request: gda_tag.CreateTagRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_tag.CreateTagRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_tag - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_create_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: - """Post-rpc interceptor for create_tag - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_delete_package(self, request: package.DeletePackageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[package.DeletePackageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_package - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_delete_package(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_package - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_delete_repository(self, request: repository.DeleteRepositoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[repository.DeleteRepositoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_repository - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_delete_repository(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_repository - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_delete_tag(self, request: tag.DeleteTagRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[tag.DeleteTagRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_tag - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def pre_delete_version(self, request: version.DeleteVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_delete_version(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_version - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_file(self, request: file.GetFileRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[file.GetFileRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_file - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_file(self, response: file.File) -> file.File: - """Post-rpc interceptor for get_file - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_iam_policy(self, request: iam_policy_pb2.GetIamPolicyRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_iam_policy - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: - """Post-rpc interceptor for get_iam_policy - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_package(self, request: package.GetPackageRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[package.GetPackageRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_package - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_package(self, response: package.Package) -> package.Package: - """Post-rpc interceptor for get_package - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_project_settings(self, request: settings.GetProjectSettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[settings.GetProjectSettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_project_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_project_settings(self, response: settings.ProjectSettings) -> settings.ProjectSettings: - """Post-rpc interceptor for get_project_settings - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_repository(self, request: repository.GetRepositoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[repository.GetRepositoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_repository - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_repository(self, response: repository.Repository) -> repository.Repository: - """Post-rpc interceptor for get_repository - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_tag(self, request: tag.GetTagRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[tag.GetTagRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_tag - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_tag(self, response: tag.Tag) -> tag.Tag: - """Post-rpc interceptor for get_tag - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_version(self, request: version.GetVersionRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_version - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_version(self, response: version.Version) -> version.Version: - """Post-rpc interceptor for get_version - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_import_apt_artifacts(self, request: apt_artifact.ImportAptArtifactsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[apt_artifact.ImportAptArtifactsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for import_apt_artifacts - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_import_apt_artifacts(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for import_apt_artifacts - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_import_yum_artifacts(self, request: yum_artifact.ImportYumArtifactsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[yum_artifact.ImportYumArtifactsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for import_yum_artifacts - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_import_yum_artifacts(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for import_yum_artifacts - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_files(self, request: file.ListFilesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[file.ListFilesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_files - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_files(self, response: file.ListFilesResponse) -> file.ListFilesResponse: - """Post-rpc interceptor for list_files - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_packages(self, request: package.ListPackagesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[package.ListPackagesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_packages - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_packages(self, response: package.ListPackagesResponse) -> package.ListPackagesResponse: - """Post-rpc interceptor for list_packages - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_repositories(self, request: repository.ListRepositoriesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[repository.ListRepositoriesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_repositories - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_repositories(self, response: repository.ListRepositoriesResponse) -> repository.ListRepositoriesResponse: - """Post-rpc interceptor for list_repositories - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_tags(self, request: tag.ListTagsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[tag.ListTagsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_tags - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_tags(self, response: tag.ListTagsResponse) -> tag.ListTagsResponse: - """Post-rpc interceptor for list_tags - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_versions(self, request: version.ListVersionsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_versions - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_versions(self, response: version.ListVersionsResponse) -> version.ListVersionsResponse: - """Post-rpc interceptor for list_versions - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_set_iam_policy(self, request: iam_policy_pb2.SetIamPolicyRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for set_iam_policy - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: - """Post-rpc interceptor for set_iam_policy - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_test_iam_permissions(self, request: iam_policy_pb2.TestIamPermissionsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for test_iam_permissions - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_test_iam_permissions(self, response: iam_policy_pb2.TestIamPermissionsResponse) -> iam_policy_pb2.TestIamPermissionsResponse: - """Post-rpc interceptor for test_iam_permissions - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_project_settings(self, request: settings.UpdateProjectSettingsRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[settings.UpdateProjectSettingsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_project_settings - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_project_settings(self, response: settings.ProjectSettings) -> settings.ProjectSettings: - """Post-rpc interceptor for update_project_settings - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_repository(self, request: gda_repository.UpdateRepositoryRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_repository.UpdateRepositoryRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_repository - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_repository(self, response: gda_repository.Repository) -> gda_repository.Repository: - """Post-rpc interceptor for update_repository - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_update_tag(self, request: gda_tag.UpdateTagRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[gda_tag.UpdateTagRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_tag - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_update_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: - """Post-rpc interceptor for update_tag - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the ArtifactRegistry server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the ArtifactRegistry server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class ArtifactRegistryRestStub: - _session: AuthorizedSession - _host: str - _interceptor: ArtifactRegistryRestInterceptor - - -class ArtifactRegistryRestTransport(_BaseArtifactRegistryRestTransport): - """REST backend synchronous transport for ArtifactRegistry. - - The Artifact Registry API service. - - Artifact Registry is an artifact management system for storing - artifacts from different package management systems. - - The resources managed by this API are: - - - Repositories, which group packages and their data. - - Packages, which group versions and their tags. - - Versions, which are specific forms of a package. - - Tags, which represent alternative names for versions. - - Files, which contain content and are optionally associated with a - Package or Version. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends JSON representations of protocol buffers over HTTP/1.1 - """ - - def __init__(self, *, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - client_cert_source_for_mtls: Optional[Callable[[ - ], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = 'https', - interceptor: Optional[ArtifactRegistryRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client - certificate to configure mutual TLS HTTP channel. It is ignored - if ``channel`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. - # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the - # credentials object - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - url_scheme=url_scheme, - api_audience=api_audience - ) - self._session = AuthorizedSession( - self._credentials, default_host=self.DEFAULT_HOST) - self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or ArtifactRegistryRestInterceptor() - self._prep_wrapped_messages(client_info) - - @property - def operations_client(self) -> operations_v1.AbstractOperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Only create a new client if we do not already have one. - if self._operations_client is None: - http_options: Dict[str, List[Dict[str, str]]] = { - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*/locations/*/operations/*}', - }, - ], - } - - rest_transport = operations_v1.OperationsRestTransport( - host=self._host, - # use the credentials which are saved - credentials=self._credentials, - scopes=self._scopes, - http_options=http_options, - path_prefix="v1beta2") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _CreateRepository(_BaseArtifactRegistryRestTransport._BaseCreateRepository, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.CreateRepository") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_repository.CreateRepositoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the create repository method over HTTP. - - Args: - request (~.gda_repository.CreateRepositoryRequest): - The request object. The request to create a new - repository. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_http_options() - request, metadata = self._interceptor.pre_create_repository(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._CreateRepository._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_repository(resp) - return resp - - class _CreateTag(_BaseArtifactRegistryRestTransport._BaseCreateTag, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.CreateTag") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_tag.CreateTagRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_tag.Tag: - r"""Call the create tag method over HTTP. - - Args: - request (~.gda_tag.CreateTagRequest): - The request object. The request to create a new tag. - 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: - ~.gda_tag.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_http_options() - request, metadata = self._interceptor.pre_create_tag(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._CreateTag._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_tag.Tag() - pb_resp = gda_tag.Tag.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_tag(resp) - return resp - - class _DeletePackage(_BaseArtifactRegistryRestTransport._BaseDeletePackage, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeletePackage") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: package.DeletePackageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete package method over HTTP. - - Args: - request (~.package.DeletePackageRequest): - The request object. The request to delete a package. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_http_options() - request, metadata = self._interceptor.pre_delete_package(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeletePackage._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_package(resp) - return resp - - class _DeleteRepository(_BaseArtifactRegistryRestTransport._BaseDeleteRepository, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteRepository") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: repository.DeleteRepositoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete repository method over HTTP. - - Args: - request (~.repository.DeleteRepositoryRequest): - The request object. The request to delete a repository. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_http_options() - request, metadata = self._interceptor.pre_delete_repository(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteRepository._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_repository(resp) - return resp - - class _DeleteTag(_BaseArtifactRegistryRestTransport._BaseDeleteTag, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteTag") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: tag.DeleteTagRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete tag method over HTTP. - - Args: - request (~.tag.DeleteTagRequest): - The request object. The request to delete a tag. - 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. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_http_options() - request, metadata = self._interceptor.pre_delete_tag(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteTag._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeleteVersion(_BaseArtifactRegistryRestTransport._BaseDeleteVersion, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteVersion") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: version.DeleteVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete version method over HTTP. - - Args: - request (~.version.DeleteVersionRequest): - The request object. The request to delete a version. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_http_options() - request, metadata = self._interceptor.pre_delete_version(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._DeleteVersion._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_version(resp) - return resp - - class _GetFile(_BaseArtifactRegistryRestTransport._BaseGetFile, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetFile") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: file.GetFileRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> file.File: - r"""Call the get file method over HTTP. - - Args: - request (~.file.GetFileRequest): - The request object. The request to retrieve a file. - 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: - ~.file.File: - Files store content that is - potentially associated with Packages or - Versions. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetFile._get_http_options() - request, metadata = self._interceptor.pre_get_file(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetFile._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetFile._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetFile._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = file.File() - pb_resp = file.File.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_file(resp) - return resp - - class _GetIamPolicy(_BaseArtifactRegistryRestTransport._BaseGetIamPolicy, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetIamPolicy") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: iam_policy_pb2.GetIamPolicyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> policy_pb2.Policy: - r"""Call the get iam policy method over HTTP. - - Args: - request (~.iam_policy_pb2.GetIamPolicyRequest): - The request object. Request message for ``GetIamPolicy`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which - specifies access controls for Google Cloud resources. - - A ``Policy`` is a collection of ``bindings``. A - ``binding`` binds one or more ``members``, or - principals, to a single ``role``. Principals can be user - accounts, service accounts, Google groups, and domains - (such as G Suite). A ``role`` is a named list of - permissions; each ``role`` can be an IAM predefined role - or a user-created custom role. - - For some types of Google Cloud resources, a ``binding`` - can also specify a ``condition``, which is a logical - expression that allows access to a resource only if the - expression evaluates to ``true``. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the `IAM - documentation `__. - - **JSON example:** - - :: - - { - "bindings": [ - { - "role": "roles/resourcemanager.organizationAdmin", - "members": [ - "user:mike@example.com", - "group:admins@example.com", - "domain:google.com", - "serviceAccount:my-project-id@appspot.gserviceaccount.com" - ] - }, - { - "role": "roles/resourcemanager.organizationViewer", - "members": [ - "user:eve@example.com" - ], - "condition": { - "title": "expirable access", - "description": "Does not grant access after Sep 2020", - "expression": "request.time < - timestamp('2020-10-01T00:00:00.000Z')", - } - } - ], - "etag": "BwWWja0YfJA=", - "version": 3 - } - - **YAML example:** - - :: - - bindings: - - members: - - user:mike@example.com - - group:admins@example.com - - domain:google.com - - serviceAccount:my-project-id@appspot.gserviceaccount.com - role: roles/resourcemanager.organizationAdmin - - members: - - user:eve@example.com - role: roles/resourcemanager.organizationViewer - condition: - title: expirable access - description: Does not grant access after Sep 2020 - expression: request.time < timestamp('2020-10-01T00:00:00.000Z') - etag: BwWWja0YfJA= - version: 3 - - For a description of IAM and its features, see the `IAM - documentation `__. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_http_options() - request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetIamPolicy._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = policy_pb2.Policy() - pb_resp = resp - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_iam_policy(resp) - return resp - - class _GetPackage(_BaseArtifactRegistryRestTransport._BaseGetPackage, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetPackage") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: package.GetPackageRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> package.Package: - r"""Call the get package method over HTTP. - - Args: - request (~.package.GetPackageRequest): - The request object. The request to retrieve a package. - 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: - ~.package.Package: - Packages are named collections of - versions. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetPackage._get_http_options() - request, metadata = self._interceptor.pre_get_package(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetPackage._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetPackage._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetPackage._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = package.Package() - pb_resp = package.Package.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_package(resp) - return resp - - class _GetProjectSettings(_BaseArtifactRegistryRestTransport._BaseGetProjectSettings, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetProjectSettings") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: settings.GetProjectSettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> settings.ProjectSettings: - r"""Call the get project settings method over HTTP. - - Args: - request (~.settings.GetProjectSettingsRequest): - The request object. Gets the redirection status for a - project. - 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: - ~.settings.ProjectSettings: - The Artifact Registry settings that - apply to a Project. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_http_options() - request, metadata = self._interceptor.pre_get_project_settings(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetProjectSettings._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = settings.ProjectSettings() - pb_resp = settings.ProjectSettings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_project_settings(resp) - return resp - - class _GetRepository(_BaseArtifactRegistryRestTransport._BaseGetRepository, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetRepository") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: repository.GetRepositoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> repository.Repository: - r"""Call the get repository method over HTTP. - - Args: - request (~.repository.GetRepositoryRequest): - The request object. The request to retrieve a repository. - 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: - ~.repository.Repository: - A Repository for storing artifacts - with a specific format. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetRepository._get_http_options() - request, metadata = self._interceptor.pre_get_repository(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetRepository._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetRepository._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetRepository._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = repository.Repository() - pb_resp = repository.Repository.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_repository(resp) - return resp - - class _GetTag(_BaseArtifactRegistryRestTransport._BaseGetTag, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetTag") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: tag.GetTagRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> tag.Tag: - r"""Call the get tag method over HTTP. - - Args: - request (~.tag.GetTagRequest): - The request object. The request to retrieve a tag. - 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: - ~.tag.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetTag._get_http_options() - request, metadata = self._interceptor.pre_get_tag(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetTag._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetTag._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetTag._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = tag.Tag() - pb_resp = tag.Tag.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_tag(resp) - return resp - - class _GetVersion(_BaseArtifactRegistryRestTransport._BaseGetVersion, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetVersion") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: version.GetVersionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> version.Version: - r"""Call the get version method over HTTP. - - Args: - request (~.version.GetVersionRequest): - The request object. The request to retrieve a version. - 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: - ~.version.Version: - The body of a version resource. A - version resource represents a collection - of components, such as files and other - data. This may correspond to a version - in many package management schemes. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetVersion._get_http_options() - request, metadata = self._interceptor.pre_get_version(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetVersion._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetVersion._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetVersion._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = version.Version() - pb_resp = version.Version.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_version(resp) - return resp - - class _ImportAptArtifacts(_BaseArtifactRegistryRestTransport._BaseImportAptArtifacts, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ImportAptArtifacts") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: apt_artifact.ImportAptArtifactsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the import apt artifacts method over HTTP. - - Args: - request (~.apt_artifact.ImportAptArtifactsRequest): - The request object. The request to import new apt - artifacts. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_http_options() - request, metadata = self._interceptor.pre_import_apt_artifacts(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ImportAptArtifacts._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_import_apt_artifacts(resp) - return resp - - class _ImportYumArtifacts(_BaseArtifactRegistryRestTransport._BaseImportYumArtifacts, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ImportYumArtifacts") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: yum_artifact.ImportYumArtifactsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> operations_pb2.Operation: - r"""Call the import yum artifacts method over HTTP. - - Args: - request (~.yum_artifact.ImportYumArtifactsRequest): - The request object. The request to import new yum - artifacts. - 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: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_http_options() - request, metadata = self._interceptor.pre_import_yum_artifacts(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ImportYumArtifacts._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_import_yum_artifacts(resp) - return resp - - class _ListFiles(_BaseArtifactRegistryRestTransport._BaseListFiles, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListFiles") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: file.ListFilesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> file.ListFilesResponse: - r"""Call the list files method over HTTP. - - Args: - request (~.file.ListFilesRequest): - The request object. The request to list files. - 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: - ~.file.ListFilesResponse: - The response from listing files. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListFiles._get_http_options() - request, metadata = self._interceptor.pre_list_files(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListFiles._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListFiles._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListFiles._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = file.ListFilesResponse() - pb_resp = file.ListFilesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_files(resp) - return resp - - class _ListPackages(_BaseArtifactRegistryRestTransport._BaseListPackages, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListPackages") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: package.ListPackagesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> package.ListPackagesResponse: - r"""Call the list packages method over HTTP. - - Args: - request (~.package.ListPackagesRequest): - The request object. The request to list packages. - 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: - ~.package.ListPackagesResponse: - The response from listing packages. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListPackages._get_http_options() - request, metadata = self._interceptor.pre_list_packages(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListPackages._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListPackages._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListPackages._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = package.ListPackagesResponse() - pb_resp = package.ListPackagesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_packages(resp) - return resp - - class _ListRepositories(_BaseArtifactRegistryRestTransport._BaseListRepositories, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListRepositories") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: repository.ListRepositoriesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> repository.ListRepositoriesResponse: - r"""Call the list repositories method over HTTP. - - Args: - request (~.repository.ListRepositoriesRequest): - The request object. The request to list repositories. - 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: - ~.repository.ListRepositoriesResponse: - The response from listing - repositories. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListRepositories._get_http_options() - request, metadata = self._interceptor.pre_list_repositories(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListRepositories._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListRepositories._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListRepositories._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = repository.ListRepositoriesResponse() - pb_resp = repository.ListRepositoriesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_repositories(resp) - return resp - - class _ListTags(_BaseArtifactRegistryRestTransport._BaseListTags, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListTags") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: tag.ListTagsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> tag.ListTagsResponse: - r"""Call the list tags method over HTTP. - - Args: - request (~.tag.ListTagsRequest): - The request object. The request to list tags. - 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: - ~.tag.ListTagsResponse: - The response from listing tags. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListTags._get_http_options() - request, metadata = self._interceptor.pre_list_tags(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListTags._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListTags._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListTags._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = tag.ListTagsResponse() - pb_resp = tag.ListTagsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_tags(resp) - return resp - - class _ListVersions(_BaseArtifactRegistryRestTransport._BaseListVersions, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListVersions") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: version.ListVersionsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> version.ListVersionsResponse: - r"""Call the list versions method over HTTP. - - Args: - request (~.version.ListVersionsRequest): - The request object. The request to list versions. - 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: - ~.version.ListVersionsResponse: - The response from listing versions. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListVersions._get_http_options() - request, metadata = self._interceptor.pre_list_versions(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListVersions._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListVersions._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListVersions._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = version.ListVersionsResponse() - pb_resp = version.ListVersionsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_versions(resp) - return resp - - class _SetIamPolicy(_BaseArtifactRegistryRestTransport._BaseSetIamPolicy, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.SetIamPolicy") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: iam_policy_pb2.SetIamPolicyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> policy_pb2.Policy: - r"""Call the set iam policy method over HTTP. - - Args: - request (~.iam_policy_pb2.SetIamPolicyRequest): - The request object. Request message for ``SetIamPolicy`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which - specifies access controls for Google Cloud resources. - - A ``Policy`` is a collection of ``bindings``. A - ``binding`` binds one or more ``members``, or - principals, to a single ``role``. Principals can be user - accounts, service accounts, Google groups, and domains - (such as G Suite). A ``role`` is a named list of - permissions; each ``role`` can be an IAM predefined role - or a user-created custom role. - - For some types of Google Cloud resources, a ``binding`` - can also specify a ``condition``, which is a logical - expression that allows access to a resource only if the - expression evaluates to ``true``. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the `IAM - documentation `__. - - **JSON example:** - - :: - - { - "bindings": [ - { - "role": "roles/resourcemanager.organizationAdmin", - "members": [ - "user:mike@example.com", - "group:admins@example.com", - "domain:google.com", - "serviceAccount:my-project-id@appspot.gserviceaccount.com" - ] - }, - { - "role": "roles/resourcemanager.organizationViewer", - "members": [ - "user:eve@example.com" - ], - "condition": { - "title": "expirable access", - "description": "Does not grant access after Sep 2020", - "expression": "request.time < - timestamp('2020-10-01T00:00:00.000Z')", - } - } - ], - "etag": "BwWWja0YfJA=", - "version": 3 - } - - **YAML example:** - - :: - - bindings: - - members: - - user:mike@example.com - - group:admins@example.com - - domain:google.com - - serviceAccount:my-project-id@appspot.gserviceaccount.com - role: roles/resourcemanager.organizationAdmin - - members: - - user:eve@example.com - role: roles/resourcemanager.organizationViewer - condition: - title: expirable access - description: Does not grant access after Sep 2020 - expression: request.time < timestamp('2020-10-01T00:00:00.000Z') - etag: BwWWja0YfJA= - version: 3 - - For a description of IAM and its features, see the `IAM - documentation `__. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_http_options() - request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._SetIamPolicy._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = policy_pb2.Policy() - pb_resp = resp - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_set_iam_policy(resp) - return resp - - class _TestIamPermissions(_BaseArtifactRegistryRestTransport._BaseTestIamPermissions, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.TestIamPermissions") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: iam_policy_pb2.TestIamPermissionsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Call the test iam permissions method over HTTP. - - Args: - request (~.iam_policy_pb2.TestIamPermissionsRequest): - The request object. Request message for ``TestIamPermissions`` method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - ~.iam_policy_pb2.TestIamPermissionsResponse: - Response message for ``TestIamPermissions`` method. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_http_options() - request, metadata = self._interceptor.pre_test_iam_permissions(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._TestIamPermissions._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = iam_policy_pb2.TestIamPermissionsResponse() - pb_resp = resp - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_test_iam_permissions(resp) - return resp - - class _UpdateProjectSettings(_BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateProjectSettings") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: settings.UpdateProjectSettingsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> settings.ProjectSettings: - r"""Call the update project settings method over HTTP. - - Args: - request (~.settings.UpdateProjectSettingsRequest): - The request object. Sets the settings of the project. - 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: - ~.settings.ProjectSettings: - The Artifact Registry settings that - apply to a Project. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_http_options() - request, metadata = self._interceptor.pre_update_project_settings(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateProjectSettings._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = settings.ProjectSettings() - pb_resp = settings.ProjectSettings.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_project_settings(resp) - return resp - - class _UpdateRepository(_BaseArtifactRegistryRestTransport._BaseUpdateRepository, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateRepository") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_repository.UpdateRepositoryRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_repository.Repository: - r"""Call the update repository method over HTTP. - - Args: - request (~.gda_repository.UpdateRepositoryRequest): - The request object. The request to update a repository. - 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: - ~.gda_repository.Repository: - A Repository for storing artifacts - with a specific format. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_http_options() - request, metadata = self._interceptor.pre_update_repository(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateRepository._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_repository.Repository() - pb_resp = gda_repository.Repository.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_repository(resp) - return resp - - class _UpdateTag(_BaseArtifactRegistryRestTransport._BaseUpdateTag, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.UpdateTag") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: gda_tag.UpdateTagRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> gda_tag.Tag: - r"""Call the update tag method over HTTP. - - Args: - request (~.gda_tag.UpdateTagRequest): - The request object. The request to create or update a - tag. - 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: - ~.gda_tag.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. - - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_http_options() - request, metadata = self._interceptor.pre_update_tag(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_transcoded_request(http_options, request) - - body = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._UpdateTag._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, body) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = gda_tag.Tag() - pb_resp = gda_tag.Tag.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_tag(resp) - return resp - - @property - def create_repository(self) -> Callable[ - [gda_repository.CreateRepositoryRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateRepository(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_tag(self) -> Callable[ - [gda_tag.CreateTagRequest], - gda_tag.Tag]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateTag(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_package(self) -> Callable[ - [package.DeletePackageRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeletePackage(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_repository(self) -> Callable[ - [repository.DeleteRepositoryRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteRepository(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_tag(self) -> Callable[ - [tag.DeleteTagRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteTag(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_version(self) -> Callable[ - [version.DeleteVersionRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_file(self) -> Callable[ - [file.GetFileRequest], - file.File]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetFile(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_iam_policy(self) -> Callable[ - [iam_policy_pb2.GetIamPolicyRequest], - policy_pb2.Policy]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetIamPolicy(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_package(self) -> Callable[ - [package.GetPackageRequest], - package.Package]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetPackage(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_project_settings(self) -> Callable[ - [settings.GetProjectSettingsRequest], - settings.ProjectSettings]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetProjectSettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_repository(self) -> Callable[ - [repository.GetRepositoryRequest], - repository.Repository]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetRepository(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_tag(self) -> Callable[ - [tag.GetTagRequest], - tag.Tag]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetTag(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_version(self) -> Callable[ - [version.GetVersionRequest], - version.Version]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetVersion(self._session, self._host, self._interceptor) # type: ignore - - @property - def import_apt_artifacts(self) -> Callable[ - [apt_artifact.ImportAptArtifactsRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ImportAptArtifacts(self._session, self._host, self._interceptor) # type: ignore - - @property - def import_yum_artifacts(self) -> Callable[ - [yum_artifact.ImportYumArtifactsRequest], - operations_pb2.Operation]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ImportYumArtifacts(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_files(self) -> Callable[ - [file.ListFilesRequest], - file.ListFilesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListFiles(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_packages(self) -> Callable[ - [package.ListPackagesRequest], - package.ListPackagesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListPackages(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_repositories(self) -> Callable[ - [repository.ListRepositoriesRequest], - repository.ListRepositoriesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListRepositories(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_tags(self) -> Callable[ - [tag.ListTagsRequest], - tag.ListTagsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListTags(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_versions(self) -> Callable[ - [version.ListVersionsRequest], - version.ListVersionsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListVersions(self._session, self._host, self._interceptor) # type: ignore - - @property - def set_iam_policy(self) -> Callable[ - [iam_policy_pb2.SetIamPolicyRequest], - policy_pb2.Policy]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._SetIamPolicy(self._session, self._host, self._interceptor) # type: ignore - - @property - def test_iam_permissions(self) -> Callable[ - [iam_policy_pb2.TestIamPermissionsRequest], - iam_policy_pb2.TestIamPermissionsResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._TestIamPermissions(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_project_settings(self) -> Callable[ - [settings.UpdateProjectSettingsRequest], - settings.ProjectSettings]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateProjectSettings(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_repository(self) -> Callable[ - [gda_repository.UpdateRepositoryRequest], - gda_repository.Repository]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateRepository(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_tag(self) -> Callable[ - [gda_tag.UpdateTagRequest], - gda_tag.Tag]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateTag(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(_BaseArtifactRegistryRestTransport._BaseGetLocation, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.GetLocation") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseGetLocation._get_http_options() - request, metadata = self._interceptor.pre_get_location(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetLocation._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseGetLocation._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._GetLocation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - content = response.content.decode("utf-8") - resp = locations_pb2.Location() - resp = json_format.Parse(content, resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(_BaseArtifactRegistryRestTransport._BaseListLocations, ArtifactRegistryRestStub): - def __hash__(self): - return hash("ArtifactRegistryRestTransport.ListLocations") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options = _BaseArtifactRegistryRestTransport._BaseListLocations._get_http_options() - request, metadata = self._interceptor.pre_list_locations(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseListLocations._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseListLocations._get_query_params_json(transcoded_request) - - # Send the request - response = ArtifactRegistryRestTransport._ListLocations._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - content = response.content.decode("utf-8") - resp = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(content, resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def kind(self) -> str: - return "rest" - - def close(self): - self._session.close() - - -__all__=( - 'ArtifactRegistryRestTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest_base.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest_base.py deleted file mode 100644 index 39e42437d3ff..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest_base.py +++ /dev/null @@ -1,1034 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import json # type: ignore -from google.api_core import path_template -from google.api_core import gapic_v1 - -from google.protobuf import json_format -from google.cloud.location import locations_pb2 # type: ignore -from .base import ArtifactRegistryTransport, DEFAULT_CLIENT_INFO - -import re -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union - - -from google.cloud.artifactregistry_v1beta2.types import apt_artifact -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository -from google.cloud.artifactregistry_v1beta2.types import settings -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag -from google.cloud.artifactregistry_v1beta2.types import version -from google.cloud.artifactregistry_v1beta2.types import yum_artifact -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.longrunning import operations_pb2 # type: ignore - - -class _BaseArtifactRegistryRestTransport(ArtifactRegistryTransport): - """Base REST backend transport for ArtifactRegistry. - - Note: This class is not meant to be used directly. Use its sync and - async sub-classes instead. - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends JSON representations of protocol buffers over HTTP/1.1 - """ - - def __init__(self, *, - host: str = 'artifactregistry.googleapis.com', - credentials: Optional[Any] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = 'https', - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - Args: - host (Optional[str]): - The hostname to connect to (default: 'artifactregistry.googleapis.com'). - credentials (Optional[Any]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) - if maybe_url_match is None: - raise ValueError(f"Unexpected hostname structure: {host}") # pragma: NO COVER - - url_match_items = maybe_url_match.groupdict() - - host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host - - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience - ) - - class _BaseCreateRepository: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1beta2/{parent=projects/*/locations/*}/repositories', - 'body': 'repository', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_repository.CreateRepositoryRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseCreateRepository._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseCreateTag: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1beta2/{parent=projects/*/locations/*/repositories/*/packages/*}/tags', - 'body': 'tag', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_tag.CreateTagRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeletePackage: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = package.DeletePackageRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteRepository: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = repository.DeleteRepositoryRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteTag: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = tag.DeleteTagRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseDeleteVersion: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = version.DeleteVersionRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetFile: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*/files/**}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = file.GetFileRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetIamPolicy: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{resource=projects/*/locations/*/repositories/*}:getIamPolicy', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = request - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetPackage: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = package.GetPackageRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetProjectSettings: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*/projectSettings}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = settings.GetProjectSettingsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetRepository: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = repository.GetRepositoryRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseGetRepository._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetTag: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = tag.GetTagRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetVersion: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = version.GetVersionRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseImportAptArtifacts: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1beta2/{parent=projects/*/locations/*/repositories/*}/aptArtifacts:import', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = apt_artifact.ImportAptArtifactsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseImportYumArtifacts: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1beta2/{parent=projects/*/locations/*/repositories/*}/yumArtifacts:import', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = yum_artifact.ImportYumArtifactsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListFiles: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{parent=projects/*/locations/*/repositories/*}/files', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = file.ListFilesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListPackages: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{parent=projects/*/locations/*/repositories/*}/packages', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = package.ListPackagesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListRepositories: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{parent=projects/*/locations/*}/repositories', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = repository.ListRepositoriesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseListRepositories._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListTags: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{parent=projects/*/locations/*/repositories/*/packages/*}/tags', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = tag.ListTagsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseListVersions: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{parent=projects/*/locations/*/repositories/*/packages/*}/versions', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = version.ListVersionsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseSetIamPolicy: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1beta2/{resource=projects/*/locations/*/repositories/*}:setIamPolicy', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = request - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseTestIamPermissions: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1beta2/{resource=projects/*/locations/*/repositories/*}:testIamPermissions', - 'body': '*', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = request - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateProjectSettings: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1beta2/{project_settings.name=projects/*/projectSettings}', - 'body': 'project_settings', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = settings.UpdateProjectSettingsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateRepository: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1beta2/{repository.name=projects/*/locations/*/repositories/*}', - 'body': 'repository', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_repository.UpdateRepositoryRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseUpdateTag: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1beta2/{tag.name=projects/*/locations/*/repositories/*/packages/*/tags/*}', - 'body': 'tag', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - pb_request = gda_tag.UpdateTagRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - return transcoded_request - - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True - ) - return body - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - - query_params["$alt"] = "json;enum-encoding=int" - return query_params - - class _BaseGetLocation: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*/locations/*}', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - return query_params - - class _BaseListLocations: - def __hash__(self): # pragma: NO COVER - return NotImplementedError("__hash__ must be implemented.") - - @staticmethod - def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1beta2/{name=projects/*}/locations', - }, - ] - return http_options - - @staticmethod - def _get_transcoded_request(http_options, request): - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - return transcoded_request - - @staticmethod - def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - return query_params - - -__all__=( - '_BaseArtifactRegistryRestTransport', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/__init__.py deleted file mode 100644 index 974deb6aae5e..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/__init__.py +++ /dev/null @@ -1,128 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 .apt_artifact import ( - AptArtifact, - ImportAptArtifactsErrorInfo, - ImportAptArtifactsGcsSource, - ImportAptArtifactsMetadata, - ImportAptArtifactsRequest, - ImportAptArtifactsResponse, -) -from .file import ( - File, - GetFileRequest, - Hash, - ListFilesRequest, - ListFilesResponse, -) -from .package import ( - DeletePackageRequest, - GetPackageRequest, - ListPackagesRequest, - ListPackagesResponse, - Package, -) -from .repository import ( - CreateRepositoryRequest, - DeleteRepositoryRequest, - GetRepositoryRequest, - ListRepositoriesRequest, - ListRepositoriesResponse, - Repository, - UpdateRepositoryRequest, -) -from .service import ( - OperationMetadata, -) -from .settings import ( - GetProjectSettingsRequest, - ProjectSettings, - UpdateProjectSettingsRequest, -) -from .tag import ( - CreateTagRequest, - DeleteTagRequest, - GetTagRequest, - ListTagsRequest, - ListTagsResponse, - Tag, - UpdateTagRequest, -) -from .version import ( - DeleteVersionRequest, - GetVersionRequest, - ListVersionsRequest, - ListVersionsResponse, - Version, - VersionView, -) -from .yum_artifact import ( - ImportYumArtifactsErrorInfo, - ImportYumArtifactsGcsSource, - ImportYumArtifactsMetadata, - ImportYumArtifactsRequest, - ImportYumArtifactsResponse, - YumArtifact, -) - -__all__ = ( - 'AptArtifact', - 'ImportAptArtifactsErrorInfo', - 'ImportAptArtifactsGcsSource', - 'ImportAptArtifactsMetadata', - 'ImportAptArtifactsRequest', - 'ImportAptArtifactsResponse', - 'File', - 'GetFileRequest', - 'Hash', - 'ListFilesRequest', - 'ListFilesResponse', - 'DeletePackageRequest', - 'GetPackageRequest', - 'ListPackagesRequest', - 'ListPackagesResponse', - 'Package', - 'CreateRepositoryRequest', - 'DeleteRepositoryRequest', - 'GetRepositoryRequest', - 'ListRepositoriesRequest', - 'ListRepositoriesResponse', - 'Repository', - 'UpdateRepositoryRequest', - 'OperationMetadata', - 'GetProjectSettingsRequest', - 'ProjectSettings', - 'UpdateProjectSettingsRequest', - 'CreateTagRequest', - 'DeleteTagRequest', - 'GetTagRequest', - 'ListTagsRequest', - 'ListTagsResponse', - 'Tag', - 'UpdateTagRequest', - 'DeleteVersionRequest', - 'GetVersionRequest', - 'ListVersionsRequest', - 'ListVersionsResponse', - 'Version', - 'VersionView', - 'ImportYumArtifactsErrorInfo', - 'ImportYumArtifactsGcsSource', - 'ImportYumArtifactsMetadata', - 'ImportYumArtifactsRequest', - 'ImportYumArtifactsResponse', - 'YumArtifact', -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/apt_artifact.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/apt_artifact.py deleted file mode 100644 index 978cfaa9907e..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/apt_artifact.py +++ /dev/null @@ -1,210 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.rpc import status_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'AptArtifact', - 'ImportAptArtifactsGcsSource', - 'ImportAptArtifactsRequest', - 'ImportAptArtifactsErrorInfo', - 'ImportAptArtifactsResponse', - 'ImportAptArtifactsMetadata', - }, -) - - -class AptArtifact(proto.Message): - r"""A detailed representation of an Apt artifact. Information in - the record is derived from the archive's control file. See - https://www.debian.org/doc/debian-policy/ch-controlfields.html - - Attributes: - name (str): - Output only. The Artifact Registry resource - name of the artifact. - package_name (str): - Output only. The Apt package name of the - artifact. - package_type (google.cloud.artifactregistry_v1beta2.types.AptArtifact.PackageType): - Output only. An artifact is a binary or - source package. - architecture (str): - Output only. Operating system architecture of - the artifact. - component (str): - Output only. Repository component of the - artifact. - control_file (bytes): - Output only. Contents of the artifact's - control metadata file. - """ - class PackageType(proto.Enum): - r"""Package type is either binary or source. - - Values: - PACKAGE_TYPE_UNSPECIFIED (0): - Package type is not specified. - BINARY (1): - Binary package. - SOURCE (2): - Source package. - """ - PACKAGE_TYPE_UNSPECIFIED = 0 - BINARY = 1 - SOURCE = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - package_name: str = proto.Field( - proto.STRING, - number=2, - ) - package_type: PackageType = proto.Field( - proto.ENUM, - number=3, - enum=PackageType, - ) - architecture: str = proto.Field( - proto.STRING, - number=4, - ) - component: str = proto.Field( - proto.STRING, - number=5, - ) - control_file: bytes = proto.Field( - proto.BYTES, - number=6, - ) - - -class ImportAptArtifactsGcsSource(proto.Message): - r"""Google Cloud Storage location where the artifacts currently - reside. - - Attributes: - uris (MutableSequence[str]): - Cloud Storage paths URI (e.g., gs://my_bucket//my_object). - use_wildcards (bool): - Supports URI wildcards for matching multiple - objects from a single URI. - """ - - uris: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - use_wildcards: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class ImportAptArtifactsRequest(proto.Message): - r"""The request to import new apt artifacts. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.artifactregistry_v1beta2.types.ImportAptArtifactsGcsSource): - Google Cloud Storage location where input - content is located. - - This field is a member of `oneof`_ ``source``. - parent (str): - The name of the parent resource where the - artifacts will be imported. - """ - - gcs_source: 'ImportAptArtifactsGcsSource' = proto.Field( - proto.MESSAGE, - number=2, - oneof='source', - message='ImportAptArtifactsGcsSource', - ) - parent: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ImportAptArtifactsErrorInfo(proto.Message): - r"""Error information explaining why a package was not imported. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.artifactregistry_v1beta2.types.ImportAptArtifactsGcsSource): - Google Cloud Storage location requested. - - This field is a member of `oneof`_ ``source``. - error (google.rpc.status_pb2.Status): - The detailed error status. - """ - - gcs_source: 'ImportAptArtifactsGcsSource' = proto.Field( - proto.MESSAGE, - number=1, - oneof='source', - message='ImportAptArtifactsGcsSource', - ) - error: status_pb2.Status = proto.Field( - proto.MESSAGE, - number=2, - message=status_pb2.Status, - ) - - -class ImportAptArtifactsResponse(proto.Message): - r"""The response message from importing APT artifacts. - - Attributes: - apt_artifacts (MutableSequence[google.cloud.artifactregistry_v1beta2.types.AptArtifact]): - The Apt artifacts imported. - errors (MutableSequence[google.cloud.artifactregistry_v1beta2.types.ImportAptArtifactsErrorInfo]): - Detailed error info for artifacts that were - not imported. - """ - - apt_artifacts: MutableSequence['AptArtifact'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='AptArtifact', - ) - errors: MutableSequence['ImportAptArtifactsErrorInfo'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='ImportAptArtifactsErrorInfo', - ) - - -class ImportAptArtifactsMetadata(proto.Message): - r"""The operation metadata for importing artifacts. - """ - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/file.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/file.py deleted file mode 100644 index 32dd38833c1a..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/file.py +++ /dev/null @@ -1,213 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'Hash', - 'File', - 'ListFilesRequest', - 'ListFilesResponse', - 'GetFileRequest', - }, -) - - -class Hash(proto.Message): - r"""A hash of file content. - - Attributes: - type_ (google.cloud.artifactregistry_v1beta2.types.Hash.HashType): - The algorithm used to compute the hash value. - value (bytes): - The hash value. - """ - class HashType(proto.Enum): - r"""The algorithm used to compute the hash. - - Values: - HASH_TYPE_UNSPECIFIED (0): - Unspecified. - SHA256 (1): - SHA256 hash. - MD5 (2): - MD5 hash. - """ - HASH_TYPE_UNSPECIFIED = 0 - SHA256 = 1 - MD5 = 2 - - type_: HashType = proto.Field( - proto.ENUM, - number=1, - enum=HashType, - ) - value: bytes = proto.Field( - proto.BYTES, - number=2, - ) - - -class File(proto.Message): - r"""Files store content that is potentially associated with - Packages or Versions. - - Attributes: - name (str): - The name of the file, for example: - - "projects/p1/locations/us-central1/repositories/repo1/files/a%2Fb%2Fc.txt". - If the file ID part contains slashes, they are - escaped. - size_bytes (int): - The size of the File in bytes. - hashes (MutableSequence[google.cloud.artifactregistry_v1beta2.types.Hash]): - The hashes of the file content. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the File was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the File was last updated. - owner (str): - The name of the Package or Version that owns - this file, if any. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - size_bytes: int = proto.Field( - proto.INT64, - number=3, - ) - hashes: MutableSequence['Hash'] = proto.RepeatedField( - proto.MESSAGE, - number=4, - message='Hash', - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - owner: str = proto.Field( - proto.STRING, - number=7, - ) - - -class ListFilesRequest(proto.Message): - r"""The request to list files. - - Attributes: - parent (str): - 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. - Filter rules are case insensitive. The fields eligible for - filtering are: - - - ``name`` - - ``owner`` - - An example of using a filter: - - - ``name="projects/p1/locations/us-central1/repositories/repo1/files/a/b/*"`` - --> Files with an ID starting with "a/b/". - - ``owner="projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/1.0"`` - --> Files owned by the version ``1.0`` in package - ``pkg1``. - page_size (int): - The maximum number of files 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, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - - -class ListFilesResponse(proto.Message): - r"""The response from listing files. - - Attributes: - files (MutableSequence[google.cloud.artifactregistry_v1beta2.types.File]): - The files returned. - next_page_token (str): - The token to retrieve the next page of files, - or empty if there are no more files to return. - """ - - @property - def raw_page(self): - return self - - files: MutableSequence['File'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='File', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetFileRequest(proto.Message): - r"""The request to retrieve a file. - - Attributes: - name (str): - The name of the file to retrieve. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/package.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/package.py deleted file mode 100644 index 86937f76c552..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/package.py +++ /dev/null @@ -1,159 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'Package', - 'ListPackagesRequest', - 'ListPackagesResponse', - 'GetPackageRequest', - 'DeletePackageRequest', - }, -) - - -class Package(proto.Message): - r"""Packages are named collections of versions. - - Attributes: - name (str): - The name of the package, for example: - - "projects/p1/locations/us-central1/repositories/repo1/packages/pkg1". - display_name (str): - The display name of the package. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the package was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the package was last updated. - This includes publishing a new version of the - package. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - - -class ListPackagesRequest(proto.Message): - r"""The request to list packages. - - Attributes: - parent (str): - The name of the parent resource whose - packages will be listed. - page_size (int): - The maximum number of packages to return. - Maximum page size is 10,000. - 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 ListPackagesResponse(proto.Message): - r"""The response from listing packages. - - Attributes: - packages (MutableSequence[google.cloud.artifactregistry_v1beta2.types.Package]): - The packages returned. - next_page_token (str): - The token to retrieve the next page of - packages, or empty if there are no more packages - to return. - """ - - @property - def raw_page(self): - return self - - packages: MutableSequence['Package'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Package', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetPackageRequest(proto.Message): - r"""The request to retrieve a package. - - Attributes: - name (str): - The name of the package to retrieve. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeletePackageRequest(proto.Message): - r"""The request to delete a package. - - Attributes: - name (str): - The name of the package to delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/repository.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/repository.py deleted file mode 100644 index a2013016ce7c..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/repository.py +++ /dev/null @@ -1,331 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'Repository', - 'ListRepositoriesRequest', - 'ListRepositoriesResponse', - 'GetRepositoryRequest', - 'CreateRepositoryRequest', - 'UpdateRepositoryRequest', - 'DeleteRepositoryRequest', - }, -) - - -class Repository(proto.Message): - r"""A Repository for storing artifacts with a specific format. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - maven_config (google.cloud.artifactregistry_v1beta2.types.Repository.MavenRepositoryConfig): - Maven repository config contains repository - level configuration for the repositories of - maven type. - - This field is a member of `oneof`_ ``format_config``. - name (str): - The name of the repository, for example: - - "projects/p1/locations/us-central1/repositories/repo1". - format_ (google.cloud.artifactregistry_v1beta2.types.Repository.Format): - The format of packages that are stored in the - repository. - description (str): - The user-provided description of the - repository. - labels (MutableMapping[str, str]): - Labels with user-defined metadata. - This field may contain up to 64 entries. Label - keys and values may be no longer than 63 - characters. Label keys must begin with a - lowercase letter and may only contain lowercase - letters, numeric characters, underscores, and - dashes. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the repository was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the repository was last - updated. - kms_key_name (str): - The Cloud KMS resource name of the customer managed - encryption key that’s used to encrypt the contents of the - Repository. Has the form: - ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``. - This value may not be changed after the Repository has been - created. - """ - class Format(proto.Enum): - r"""A package format. - - Values: - FORMAT_UNSPECIFIED (0): - Unspecified package format. - DOCKER (1): - Docker package format. - MAVEN (2): - Maven package format. - NPM (3): - NPM package format. - APT (5): - APT package format. - YUM (6): - YUM package format. - PYTHON (8): - Python package format. - """ - FORMAT_UNSPECIFIED = 0 - DOCKER = 1 - MAVEN = 2 - NPM = 3 - APT = 5 - YUM = 6 - PYTHON = 8 - - class MavenRepositoryConfig(proto.Message): - r"""MavenRepositoryConfig is maven related repository details. - Provides additional configuration details for repositories of - the maven format type. - - Attributes: - allow_snapshot_overwrites (bool): - The repository with this flag will allow - publishing the same snapshot versions. - version_policy (google.cloud.artifactregistry_v1beta2.types.Repository.MavenRepositoryConfig.VersionPolicy): - Version policy defines the versions that the - registry will accept. - """ - class VersionPolicy(proto.Enum): - r"""VersionPolicy is the version policy for the repository. - - Values: - VERSION_POLICY_UNSPECIFIED (0): - VERSION_POLICY_UNSPECIFIED - the version policy is not - defined. When the version policy is not defined, no - validation is performed for the versions. - RELEASE (1): - RELEASE - repository will accept only Release - versions. - SNAPSHOT (2): - SNAPSHOT - repository will accept only - Snapshot versions. - """ - VERSION_POLICY_UNSPECIFIED = 0 - RELEASE = 1 - SNAPSHOT = 2 - - allow_snapshot_overwrites: bool = proto.Field( - proto.BOOL, - number=1, - ) - version_policy: 'Repository.MavenRepositoryConfig.VersionPolicy' = proto.Field( - proto.ENUM, - number=2, - enum='Repository.MavenRepositoryConfig.VersionPolicy', - ) - - maven_config: MavenRepositoryConfig = proto.Field( - proto.MESSAGE, - number=9, - oneof='format_config', - message=MavenRepositoryConfig, - ) - name: str = proto.Field( - proto.STRING, - number=1, - ) - format_: Format = proto.Field( - proto.ENUM, - number=2, - enum=Format, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - kms_key_name: str = proto.Field( - proto.STRING, - number=8, - ) - - -class ListRepositoriesRequest(proto.Message): - r"""The request to list repositories. - - Attributes: - parent (str): - Required. The name of the parent resource - whose repositories will be listed. - page_size (int): - The maximum number of repositories to return. - Maximum page size is 1,000. - 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 ListRepositoriesResponse(proto.Message): - r"""The response from listing repositories. - - Attributes: - repositories (MutableSequence[google.cloud.artifactregistry_v1beta2.types.Repository]): - The repositories returned. - next_page_token (str): - The token to retrieve the next page of - repositories, or empty if there are no more - repositories to return. - """ - - @property - def raw_page(self): - return self - - repositories: MutableSequence['Repository'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Repository', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetRepositoryRequest(proto.Message): - r"""The request to retrieve a repository. - - Attributes: - name (str): - Required. The name of the repository to - retrieve. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateRepositoryRequest(proto.Message): - r"""The request to create a new repository. - - Attributes: - parent (str): - Required. The name of the parent resource - where the repository will be created. - repository_id (str): - The repository id to use for this repository. - repository (google.cloud.artifactregistry_v1beta2.types.Repository): - The repository to be created. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - repository_id: str = proto.Field( - proto.STRING, - number=2, - ) - repository: 'Repository' = proto.Field( - proto.MESSAGE, - number=3, - message='Repository', - ) - - -class UpdateRepositoryRequest(proto.Message): - r"""The request to update a repository. - - Attributes: - repository (google.cloud.artifactregistry_v1beta2.types.Repository): - The repository that replaces the resource on - the server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - repository: 'Repository' = proto.Field( - proto.MESSAGE, - number=1, - message='Repository', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteRepositoryRequest(proto.Message): - r"""The request to delete a repository. - - Attributes: - name (str): - Required. The name of the repository to - delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/service.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/service.py deleted file mode 100644 index 0751d861d3f2..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/service.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'OperationMetadata', - }, -) - - -class OperationMetadata(proto.Message): - r"""Metadata type for longrunning-operations, currently empty. - """ - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/settings.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/settings.py deleted file mode 100644 index 9ea68cebff3f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/settings.py +++ /dev/null @@ -1,119 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'ProjectSettings', - 'GetProjectSettingsRequest', - 'UpdateProjectSettingsRequest', - }, -) - - -class ProjectSettings(proto.Message): - r"""The Artifact Registry settings that apply to a Project. - - Attributes: - name (str): - The name of the project's settings. - - Always of the form: - - projects/{project-id}/projectSettings - - In update request: never set - In response: always set - legacy_redirection_state (google.cloud.artifactregistry_v1beta2.types.ProjectSettings.RedirectionState): - The redirection state of the legacy - repositories in this project. - """ - class RedirectionState(proto.Enum): - r"""The possible redirection states for legacy repositories. - - Values: - REDIRECTION_STATE_UNSPECIFIED (0): - No redirection status has been set. - REDIRECTION_FROM_GCR_IO_DISABLED (1): - Redirection is disabled. - REDIRECTION_FROM_GCR_IO_ENABLED (2): - Redirection is enabled. - REDIRECTION_FROM_GCR_IO_FINALIZED (3): - Redirection is enabled, and has been - finalized so cannot be reverted. - """ - REDIRECTION_STATE_UNSPECIFIED = 0 - REDIRECTION_FROM_GCR_IO_DISABLED = 1 - REDIRECTION_FROM_GCR_IO_ENABLED = 2 - REDIRECTION_FROM_GCR_IO_FINALIZED = 3 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - legacy_redirection_state: RedirectionState = proto.Field( - proto.ENUM, - number=2, - enum=RedirectionState, - ) - - -class GetProjectSettingsRequest(proto.Message): - r"""Gets the redirection status for a project. - - Attributes: - name (str): - Required. The name of the projectSettings - resource. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateProjectSettingsRequest(proto.Message): - r"""Sets the settings of the project. - - Attributes: - project_settings (google.cloud.artifactregistry_v1beta2.types.ProjectSettings): - The project settings. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Field mask to support partial updates. - """ - - project_settings: 'ProjectSettings' = proto.Field( - proto.MESSAGE, - number=2, - message='ProjectSettings', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=3, - message=field_mask_pb2.FieldMask, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/tag.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/tag.py deleted file mode 100644 index 9104587b89b7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/tag.py +++ /dev/null @@ -1,220 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.protobuf import field_mask_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'Tag', - 'ListTagsRequest', - 'ListTagsResponse', - 'GetTagRequest', - 'CreateTagRequest', - 'UpdateTagRequest', - 'DeleteTagRequest', - }, -) - - -class Tag(proto.Message): - r"""Tags point to a version and represent an alternative name - that can be used to access the version. - - Attributes: - name (str): - The name of the tag, for example: - "projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/tags/tag1". - If the package part contains slashes, the slashes are - escaped. The tag part can only have characters in - [a-zA-Z0-9-._~:@], anything else must be URL encoded. - version (str): - The name of the version the tag refers to, - for example: - "projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/sha256:5243811" - If the package or version ID parts contain - slashes, the slashes are escaped. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - version: str = proto.Field( - proto.STRING, - number=2, - ) - - -class ListTagsRequest(proto.Message): - r"""The request to list tags. - - Attributes: - parent (str): - The name of the parent resource whose tags - will be listed. - filter (str): - An expression for filtering the results of the request. - Filter rules are case insensitive. The fields eligible for - filtering are: - - - ``version`` - - An example of using a filter: - - - ``version="projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/1.0"`` - --> Tags that are applied to the version ``1.0`` in - package ``pkg1``. - page_size (int): - The maximum number of tags to return. Maximum - page size is 10,000. - page_token (str): - The next_page_token value returned from a previous list - request, if any. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - - -class ListTagsResponse(proto.Message): - r"""The response from listing tags. - - Attributes: - tags (MutableSequence[google.cloud.artifactregistry_v1beta2.types.Tag]): - The tags returned. - next_page_token (str): - The token to retrieve the next page of tags, - or empty if there are no more tags to return. - """ - - @property - def raw_page(self): - return self - - tags: MutableSequence['Tag'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Tag', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetTagRequest(proto.Message): - r"""The request to retrieve a tag. - - Attributes: - name (str): - The name of the tag to retrieve. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateTagRequest(proto.Message): - r"""The request to create a new tag. - - Attributes: - parent (str): - The name of the parent resource where the tag - will be created. - tag_id (str): - The tag id to use for this repository. - tag (google.cloud.artifactregistry_v1beta2.types.Tag): - The tag to be created. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - tag_id: str = proto.Field( - proto.STRING, - number=2, - ) - tag: 'Tag' = proto.Field( - proto.MESSAGE, - number=3, - message='Tag', - ) - - -class UpdateTagRequest(proto.Message): - r"""The request to create or update a tag. - - Attributes: - tag (google.cloud.artifactregistry_v1beta2.types.Tag): - The tag that replaces the resource on the - server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - tag: 'Tag' = proto.Field( - proto.MESSAGE, - number=1, - message='Tag', - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteTagRequest(proto.Message): - r"""The request to delete a tag. - - Attributes: - name (str): - The name of the tag to delete. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/version.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/version.py deleted file mode 100644 index 9575bbe7d640..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/version.py +++ /dev/null @@ -1,234 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.cloud.artifactregistry_v1beta2.types import tag -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'VersionView', - 'Version', - 'ListVersionsRequest', - 'ListVersionsResponse', - 'GetVersionRequest', - 'DeleteVersionRequest', - }, -) - - -class VersionView(proto.Enum): - r"""The view, which determines what version information is - returned in a response. - - Values: - VERSION_VIEW_UNSPECIFIED (0): - The default / unset value. - The API will default to the BASIC view. - BASIC (1): - Includes basic information about the version, - but not any related tags. - FULL (2): - Include everything. - """ - VERSION_VIEW_UNSPECIFIED = 0 - BASIC = 1 - FULL = 2 - - -class Version(proto.Message): - r"""The body of a version resource. A version resource represents - a collection of components, such as files and other data. This - may correspond to a version in many package management schemes. - - Attributes: - name (str): - The name of the version, for example: - - "projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/art1". - If the package or version ID parts contain - slashes, the slashes are escaped. - description (str): - Optional. Description of the version, as - specified in its metadata. - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the version was created. - update_time (google.protobuf.timestamp_pb2.Timestamp): - The time when the version was last updated. - related_tags (MutableSequence[google.cloud.artifactregistry_v1beta2.types.Tag]): - Output only. A list of related tags. Will - contain up to 100 tags that reference this - version. - 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 - [DockerImage][google.devtools.artifactregistry.v1.DockerImage] - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=6, - message=timestamp_pb2.Timestamp, - ) - related_tags: MutableSequence[tag.Tag] = proto.RepeatedField( - proto.MESSAGE, - number=7, - message=tag.Tag, - ) - metadata: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=8, - message=struct_pb2.Struct, - ) - - -class ListVersionsRequest(proto.Message): - r"""The request to list versions. - - Attributes: - parent (str): - The name of the parent resource whose - versions will be listed. - page_size (int): - The maximum number of versions to return. - Maximum page size is 1,000. - page_token (str): - The next_page_token value returned from a previous list - request, if any. - view (google.cloud.artifactregistry_v1beta2.types.VersionView): - The view that should be returned in the - response. - order_by (str): - Optional. The field to order the results by. - """ - - 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, - ) - view: 'VersionView' = proto.Field( - proto.ENUM, - number=4, - enum='VersionView', - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListVersionsResponse(proto.Message): - r"""The response from listing versions. - - Attributes: - versions (MutableSequence[google.cloud.artifactregistry_v1beta2.types.Version]): - The versions returned. - next_page_token (str): - The token to retrieve the next page of - versions, or empty if there are no more versions - to return. - """ - - @property - def raw_page(self): - return self - - versions: MutableSequence['Version'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Version', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetVersionRequest(proto.Message): - r"""The request to retrieve a version. - - Attributes: - name (str): - The name of the version to retrieve. - view (google.cloud.artifactregistry_v1beta2.types.VersionView): - The view that should be returned in the - response. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - view: 'VersionView' = proto.Field( - proto.ENUM, - number=2, - enum='VersionView', - ) - - -class DeleteVersionRequest(proto.Message): - r"""The request to delete a version. - - Attributes: - name (str): - The name of the version to delete. - force (bool): - By default, a version that is tagged may not - be deleted. If force=true, the version and any - tags pointing to the version are deleted. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - force: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/yum_artifact.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/yum_artifact.py deleted file mode 100644 index 2bbb76c4e732..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/google/cloud/artifactregistry_v1beta2/types/yum_artifact.py +++ /dev/null @@ -1,194 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.rpc import status_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1beta2', - manifest={ - 'YumArtifact', - 'ImportYumArtifactsGcsSource', - 'ImportYumArtifactsRequest', - 'ImportYumArtifactsErrorInfo', - 'ImportYumArtifactsResponse', - 'ImportYumArtifactsMetadata', - }, -) - - -class YumArtifact(proto.Message): - r"""A detailed representation of a Yum artifact. - - Attributes: - name (str): - Output only. The Artifact Registry resource - name of the artifact. - package_name (str): - Output only. The yum package name of the - artifact. - package_type (google.cloud.artifactregistry_v1beta2.types.YumArtifact.PackageType): - Output only. An artifact is a binary or - source package. - architecture (str): - Output only. Operating system architecture of - the artifact. - """ - class PackageType(proto.Enum): - r"""Package type is either binary or source. - - Values: - PACKAGE_TYPE_UNSPECIFIED (0): - Package type is not specified. - BINARY (1): - Binary package (.rpm). - SOURCE (2): - Source package (.srpm). - """ - PACKAGE_TYPE_UNSPECIFIED = 0 - BINARY = 1 - SOURCE = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - package_name: str = proto.Field( - proto.STRING, - number=2, - ) - package_type: PackageType = proto.Field( - proto.ENUM, - number=3, - enum=PackageType, - ) - architecture: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ImportYumArtifactsGcsSource(proto.Message): - r"""Google Cloud Storage location where the artifacts currently - reside. - - Attributes: - uris (MutableSequence[str]): - Cloud Storage paths URI (e.g., gs://my_bucket//my_object). - use_wildcards (bool): - Supports URI wildcards for matching multiple - objects from a single URI. - """ - - uris: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - use_wildcards: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class ImportYumArtifactsRequest(proto.Message): - r"""The request to import new yum artifacts. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.artifactregistry_v1beta2.types.ImportYumArtifactsGcsSource): - Google Cloud Storage location where input - content is located. - - This field is a member of `oneof`_ ``source``. - parent (str): - The name of the parent resource where the - artifacts will be imported. - """ - - gcs_source: 'ImportYumArtifactsGcsSource' = proto.Field( - proto.MESSAGE, - number=2, - oneof='source', - message='ImportYumArtifactsGcsSource', - ) - parent: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ImportYumArtifactsErrorInfo(proto.Message): - r"""Error information explaining why a package was not imported. - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_source (google.cloud.artifactregistry_v1beta2.types.ImportYumArtifactsGcsSource): - Google Cloud Storage location requested. - - This field is a member of `oneof`_ ``source``. - error (google.rpc.status_pb2.Status): - The detailed error status. - """ - - gcs_source: 'ImportYumArtifactsGcsSource' = proto.Field( - proto.MESSAGE, - number=1, - oneof='source', - message='ImportYumArtifactsGcsSource', - ) - error: status_pb2.Status = proto.Field( - proto.MESSAGE, - number=2, - message=status_pb2.Status, - ) - - -class ImportYumArtifactsResponse(proto.Message): - r"""The response message from importing YUM artifacts. - - Attributes: - yum_artifacts (MutableSequence[google.cloud.artifactregistry_v1beta2.types.YumArtifact]): - The yum artifacts imported. - errors (MutableSequence[google.cloud.artifactregistry_v1beta2.types.ImportYumArtifactsErrorInfo]): - Detailed error info for artifacts that were - not imported. - """ - - yum_artifacts: MutableSequence['YumArtifact'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='YumArtifact', - ) - errors: MutableSequence['ImportYumArtifactsErrorInfo'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='ImportYumArtifactsErrorInfo', - ) - - -class ImportYumArtifactsMetadata(proto.Message): - r"""The operation metadata for importing artifacts. - """ - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/mypy.ini b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/mypy.ini deleted file mode 100644 index 574c5aed394b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.7 -namespace_packages = True diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/noxfile.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/noxfile.py deleted file mode 100644 index 1f1b0b410b5d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/noxfile.py +++ /dev/null @@ -1,280 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import os -import pathlib -import re -import shutil -import subprocess -import sys - - -import nox # type: ignore - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", - "3.13", -] - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = 'google-cloud-artifact-registry' - -BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] -DEFAULT_PYTHON_VERSION = "3.13" - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", - "blacken", - "lint", - "prerelease_deps", -] - -@nox.session(python=ALL_PYTHON) -@nox.parametrize( - "protobuf_implementation", - [ "python", "upb", "cpp" ], -) -def unit(session, protobuf_implementation): - """Run the unit test suite.""" - - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): - session.skip("cpp implementation is not supported in python 3.11+") - - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - session.install('-e', '.', "-c", f"testing/constraints-{session.python}.txt") - - # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. - # The 'cpp' implementation requires Protobuf<4. - if protobuf_implementation == "cpp": - session.install("protobuf<4") - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/artifactregistry_v1beta2/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)), - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) - -@nox.session(python=ALL_PYTHON[-1]) -@nox.parametrize( - "protobuf_implementation", - [ "python", "upb", "cpp" ], -) -def prerelease_deps(session, protobuf_implementation): - """Run the unit test suite against pre-release versions of dependencies.""" - - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): - session.skip("cpp implementation is not supported in python 3.11+") - - # Install test environment dependencies - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - - # Install the package without dependencies - session.install('-e', '.', '--no-deps') - - # We test the minimum dependency versions using the minimum Python - # version so the lowest python runtime that we test has a corresponding constraints - # file, located at `testing/constraints--.txt`, which contains all of the - # dependencies and extras. - with open( - CURRENT_DIRECTORY - / "testing" - / f"constraints-{ALL_PYTHON[0]}.txt", - encoding="utf-8", - ) as constraints_file: - constraints_text = constraints_file.read() - - # Ignore leading whitespace and comment lines. - constraints_deps = [ - match.group(1) - for match in re.finditer( - r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE - ) - ] - - session.install(*constraints_deps) - - prerel_deps = [ - "googleapis-common-protos", - "google-api-core", - "google-auth", - # Exclude grpcio!=1.67.0rc1 which does not support python 3.13 - "grpcio!=1.67.0rc1", - "grpcio-status", - "protobuf", - "proto-plus", - ] - - for dep in prerel_deps: - session.install("--pre", "--no-deps", "--upgrade", dep) - - # Remaining dependencies - other_deps = [ - "requests", - ] - session.install(*other_deps) - - # Print out prerelease package versions - - session.run("python", "-c", "import google.api_core; print(google.api_core.__version__)") - session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - session.run("python", "-c", "import grpc; print(grpc.__version__)") - session.run( - "python", "-c", "import google.protobuf; print(google.protobuf.__version__)" - ) - session.run( - "python", "-c", "import proto; print(proto.__version__)" - ) - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/artifactregistry_v1beta2/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)), - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=ALL_PYTHON) -def mypy(session): - """Run the type checker.""" - session.install( - 'mypy', - 'types-requests', - 'types-protobuf' - ) - session.install('.') - session.run( - 'mypy', - '-p', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx==7.0.1", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): - """Run linters. - - Returns a failure if the linters find linting errors or sufficiently - serious code quality issues. - """ - session.install("flake8", BLACK_VERSION) - session.run( - "black", - "--check", - *BLACK_PATHS, - ) - session.run("flake8", "google", "tests", "samples") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *BLACK_PATHS, - ) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_repository_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_repository_async.py deleted file mode 100644 index d3bfa8b9d9da..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_repository_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 CreateRepository -# 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_v1beta2_generated_ArtifactRegistry_CreateRepository_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_v1beta2 - - -async def sample_create_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.CreateRepositoryRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_repository(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_CreateRepository_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_repository_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_repository_sync.py deleted file mode 100644 index e277a3ea09ec..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_repository_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 CreateRepository -# 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_v1beta2_generated_ArtifactRegistry_CreateRepository_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_v1beta2 - - -def sample_create_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.CreateRepositoryRequest( - parent="parent_value", - ) - - # Make the request - operation = client.create_repository(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_CreateRepository_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_tag_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_tag_async.py deleted file mode 100644 index 9a808c51cbf5..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_tag_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 CreateTag -# 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_v1beta2_generated_ArtifactRegistry_CreateTag_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_v1beta2 - - -async def sample_create_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.CreateTagRequest( - ) - - # Make the request - response = await client.create_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_CreateTag_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_tag_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_tag_sync.py deleted file mode 100644 index fda40279de69..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_create_tag_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 CreateTag -# 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_v1beta2_generated_ArtifactRegistry_CreateTag_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_v1beta2 - - -def sample_create_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.CreateTagRequest( - ) - - # Make the request - response = client.create_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_CreateTag_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_package_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_package_async.py deleted file mode 100644 index 1c54c32993c3..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_package_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeletePackage -# 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_v1beta2_generated_ArtifactRegistry_DeletePackage_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_v1beta2 - - -async def sample_delete_package(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeletePackageRequest( - ) - - # Make the request - operation = client.delete_package(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_DeletePackage_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_package_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_package_sync.py deleted file mode 100644 index 4b25948ff5b7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_package_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeletePackage -# 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_v1beta2_generated_ArtifactRegistry_DeletePackage_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_v1beta2 - - -def sample_delete_package(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeletePackageRequest( - ) - - # Make the request - operation = client.delete_package(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_DeletePackage_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_repository_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_repository_async.py deleted file mode 100644 index 527c7df15125..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_repository_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteRepository -# 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_v1beta2_generated_ArtifactRegistry_DeleteRepository_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_v1beta2 - - -async def sample_delete_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteRepositoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_repository(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteRepository_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_repository_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_repository_sync.py deleted file mode 100644 index d572ed247b59..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_repository_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteRepository -# 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_v1beta2_generated_ArtifactRegistry_DeleteRepository_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_v1beta2 - - -def sample_delete_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteRepositoryRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_repository(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteRepository_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_tag_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_tag_async.py deleted file mode 100644 index d4939024a3d6..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_tag_async.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteTag -# 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_v1beta2_generated_ArtifactRegistry_DeleteTag_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_v1beta2 - - -async def sample_delete_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteTagRequest( - ) - - # Make the request - await client.delete_tag(request=request) - - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteTag_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_tag_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_tag_sync.py deleted file mode 100644 index 634a54735b36..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_tag_sync.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteTag -# 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_v1beta2_generated_ArtifactRegistry_DeleteTag_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_v1beta2 - - -def sample_delete_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteTagRequest( - ) - - # Make the request - client.delete_tag(request=request) - - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteTag_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_version_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_version_async.py deleted file mode 100644 index 90e7592c5e6c..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_version_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteVersion -# 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_v1beta2_generated_ArtifactRegistry_DeleteVersion_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_v1beta2 - - -async def sample_delete_version(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteVersionRequest( - ) - - # Make the request - operation = client.delete_version(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteVersion_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_version_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_version_sync.py deleted file mode 100644 index 351ce93a6eff..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_delete_version_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 DeleteVersion -# 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_v1beta2_generated_ArtifactRegistry_DeleteVersion_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_v1beta2 - - -def sample_delete_version(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.DeleteVersionRequest( - ) - - # Make the request - operation = client.delete_version(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteVersion_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_file_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_file_async.py deleted file mode 100644 index 23ef2f2cccb4..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_file_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetFile -# 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_v1beta2_generated_ArtifactRegistry_GetFile_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_v1beta2 - - -async def sample_get_file(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetFileRequest( - ) - - # Make the request - response = await client.get_file(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetFile_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_file_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_file_sync.py deleted file mode 100644 index b958aa596d54..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_file_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetFile -# 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_v1beta2_generated_ArtifactRegistry_GetFile_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_v1beta2 - - -def sample_get_file(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetFileRequest( - ) - - # Make the request - response = client.get_file(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetFile_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_async.py deleted file mode 100644 index 89a52696735a..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetIamPolicy -# 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_v1beta2_generated_ArtifactRegistry_GetIamPolicy_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_v1beta2 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -async def sample_get_iam_policy(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = await client.get_iam_policy(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetIamPolicy_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_sync.py deleted file mode 100644 index 61af79f11a3e..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetIamPolicy -# 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_v1beta2_generated_ArtifactRegistry_GetIamPolicy_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_v1beta2 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -def sample_get_iam_policy(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = client.get_iam_policy(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetIamPolicy_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_package_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_package_async.py deleted file mode 100644 index 4b08c7e11e23..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_package_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetPackage -# 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_v1beta2_generated_ArtifactRegistry_GetPackage_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_v1beta2 - - -async def sample_get_package(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetPackageRequest( - ) - - # Make the request - response = await client.get_package(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetPackage_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_package_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_package_sync.py deleted file mode 100644 index 58af3ebf6ca9..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_package_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetPackage -# 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_v1beta2_generated_ArtifactRegistry_GetPackage_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_v1beta2 - - -def sample_get_package(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetPackageRequest( - ) - - # Make the request - response = client.get_package(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetPackage_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_async.py deleted file mode 100644 index 9cc58d4649b4..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetProjectSettings -# 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_v1beta2_generated_ArtifactRegistry_GetProjectSettings_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_v1beta2 - - -async def sample_get_project_settings(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetProjectSettingsRequest( - name="name_value", - ) - - # Make the request - response = await client.get_project_settings(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetProjectSettings_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_sync.py deleted file mode 100644 index 3c0a1a405fe9..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetProjectSettings -# 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_v1beta2_generated_ArtifactRegistry_GetProjectSettings_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_v1beta2 - - -def sample_get_project_settings(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetProjectSettingsRequest( - name="name_value", - ) - - # Make the request - response = client.get_project_settings(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetProjectSettings_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_repository_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_repository_async.py deleted file mode 100644 index 5608ef0d6907..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_repository_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetRepository -# 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_v1beta2_generated_ArtifactRegistry_GetRepository_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_v1beta2 - - -async def sample_get_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetRepositoryRequest( - name="name_value", - ) - - # Make the request - response = await client.get_repository(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetRepository_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_repository_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_repository_sync.py deleted file mode 100644 index 7f3abf474f5b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_repository_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetRepository -# 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_v1beta2_generated_ArtifactRegistry_GetRepository_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_v1beta2 - - -def sample_get_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetRepositoryRequest( - name="name_value", - ) - - # Make the request - response = client.get_repository(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetRepository_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_tag_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_tag_async.py deleted file mode 100644 index 6bc558374e64..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_tag_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetTag -# 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_v1beta2_generated_ArtifactRegistry_GetTag_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_v1beta2 - - -async def sample_get_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetTagRequest( - ) - - # Make the request - response = await client.get_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetTag_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_tag_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_tag_sync.py deleted file mode 100644 index 92fca9aefbdc..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_tag_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetTag -# 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_v1beta2_generated_ArtifactRegistry_GetTag_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_v1beta2 - - -def sample_get_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetTagRequest( - ) - - # Make the request - response = client.get_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetTag_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_version_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_version_async.py deleted file mode 100644 index 7e41f53baab9..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_version_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetVersion -# 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_v1beta2_generated_ArtifactRegistry_GetVersion_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_v1beta2 - - -async def sample_get_version(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetVersionRequest( - ) - - # Make the request - response = await client.get_version(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetVersion_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_version_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_version_sync.py deleted file mode 100644 index 8290f7a8c815..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_get_version_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 GetVersion -# 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_v1beta2_generated_ArtifactRegistry_GetVersion_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_v1beta2 - - -def sample_get_version(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.GetVersionRequest( - ) - - # Make the request - response = client.get_version(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_GetVersion_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_apt_artifacts_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_apt_artifacts_async.py deleted file mode 100644 index 5284f8b76135..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_apt_artifacts_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ImportAptArtifacts -# 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_v1beta2_generated_ArtifactRegistry_ImportAptArtifacts_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_v1beta2 - - -async def sample_import_apt_artifacts(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ImportAptArtifactsRequest( - ) - - # Make the request - operation = client.import_apt_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ImportAptArtifacts_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_apt_artifacts_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_apt_artifacts_sync.py deleted file mode 100644 index 938dfeae606a..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_apt_artifacts_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ImportAptArtifacts -# 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_v1beta2_generated_ArtifactRegistry_ImportAptArtifacts_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_v1beta2 - - -def sample_import_apt_artifacts(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ImportAptArtifactsRequest( - ) - - # Make the request - operation = client.import_apt_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ImportAptArtifacts_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_yum_artifacts_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_yum_artifacts_async.py deleted file mode 100644 index 89716c5c1c04..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_yum_artifacts_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ImportYumArtifacts -# 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_v1beta2_generated_ArtifactRegistry_ImportYumArtifacts_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_v1beta2 - - -async def sample_import_yum_artifacts(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ImportYumArtifactsRequest( - ) - - # Make the request - operation = client.import_yum_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ImportYumArtifacts_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_yum_artifacts_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_yum_artifacts_sync.py deleted file mode 100644 index 89978f616667..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_import_yum_artifacts_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ImportYumArtifacts -# 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_v1beta2_generated_ArtifactRegistry_ImportYumArtifacts_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_v1beta2 - - -def sample_import_yum_artifacts(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ImportYumArtifactsRequest( - ) - - # Make the request - operation = client.import_yum_artifacts(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ImportYumArtifacts_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_files_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_files_async.py deleted file mode 100644 index 81e0926ad17d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_files_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListFiles -# 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_v1beta2_generated_ArtifactRegistry_ListFiles_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_v1beta2 - - -async def sample_list_files(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListFilesRequest( - ) - - # Make the request - page_result = client.list_files(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListFiles_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_files_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_files_sync.py deleted file mode 100644 index b39e9d620889..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_files_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListFiles -# 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_v1beta2_generated_ArtifactRegistry_ListFiles_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_v1beta2 - - -def sample_list_files(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListFilesRequest( - ) - - # Make the request - page_result = client.list_files(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListFiles_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_packages_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_packages_async.py deleted file mode 100644 index dad94dd907e4..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_packages_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListPackages -# 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_v1beta2_generated_ArtifactRegistry_ListPackages_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_v1beta2 - - -async def sample_list_packages(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListPackagesRequest( - ) - - # Make the request - page_result = client.list_packages(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListPackages_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_packages_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_packages_sync.py deleted file mode 100644 index c16c244123f7..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_packages_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListPackages -# 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_v1beta2_generated_ArtifactRegistry_ListPackages_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_v1beta2 - - -def sample_list_packages(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListPackagesRequest( - ) - - # Make the request - page_result = client.list_packages(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListPackages_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_repositories_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_repositories_async.py deleted file mode 100644 index bde9c8e08442..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_repositories_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListRepositories -# 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_v1beta2_generated_ArtifactRegistry_ListRepositories_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_v1beta2 - - -async def sample_list_repositories(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListRepositoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_repositories(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListRepositories_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_repositories_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_repositories_sync.py deleted file mode 100644 index 922095505fd3..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_repositories_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListRepositories -# 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_v1beta2_generated_ArtifactRegistry_ListRepositories_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_v1beta2 - - -def sample_list_repositories(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListRepositoriesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_repositories(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListRepositories_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_tags_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_tags_async.py deleted file mode 100644 index dd4934f8d055..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_tags_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListTags -# 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_v1beta2_generated_ArtifactRegistry_ListTags_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_v1beta2 - - -async def sample_list_tags(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListTagsRequest( - ) - - # Make the request - page_result = client.list_tags(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListTags_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_tags_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_tags_sync.py deleted file mode 100644 index 126f3ab673ac..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_tags_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListTags -# 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_v1beta2_generated_ArtifactRegistry_ListTags_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_v1beta2 - - -def sample_list_tags(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListTagsRequest( - ) - - # Make the request - page_result = client.list_tags(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListTags_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_versions_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_versions_async.py deleted file mode 100644 index 5fc3e2222a6b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_versions_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListVersions -# 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_v1beta2_generated_ArtifactRegistry_ListVersions_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_v1beta2 - - -async def sample_list_versions(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListVersionsRequest( - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListVersions_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_versions_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_versions_sync.py deleted file mode 100644 index 9213576bedcc..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_list_versions_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 ListVersions -# 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_v1beta2_generated_ArtifactRegistry_ListVersions_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_v1beta2 - - -def sample_list_versions(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.ListVersionsRequest( - ) - - # Make the request - page_result = client.list_versions(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_ListVersions_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_async.py deleted file mode 100644 index 44542d4ea122..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 SetIamPolicy -# 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_v1beta2_generated_ArtifactRegistry_SetIamPolicy_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_v1beta2 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -async def sample_set_iam_policy(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = await client.set_iam_policy(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_SetIamPolicy_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_sync.py deleted file mode 100644 index 72bbe4ee5dee..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 SetIamPolicy -# 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_v1beta2_generated_ArtifactRegistry_SetIamPolicy_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_v1beta2 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -def sample_set_iam_policy(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) - - # Make the request - response = client.set_iam_policy(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_SetIamPolicy_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_async.py deleted file mode 100644 index 59193310e411..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_async.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 TestIamPermissions -# 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_v1beta2_generated_ArtifactRegistry_TestIamPermissions_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_v1beta2 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -async def sample_test_iam_permissions(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], - ) - - # Make the request - response = await client.test_iam_permissions(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_TestIamPermissions_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_sync.py deleted file mode 100644 index 14eff411fdff..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_sync.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 TestIamPermissions -# 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_v1beta2_generated_ArtifactRegistry_TestIamPermissions_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_v1beta2 -from google.iam.v1 import iam_policy_pb2 # type: ignore - - -def sample_test_iam_permissions(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], - ) - - # Make the request - response = client.test_iam_permissions(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_TestIamPermissions_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_async.py deleted file mode 100644 index 369f30a35d14..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateProjectSettings -# 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_v1beta2_generated_ArtifactRegistry_UpdateProjectSettings_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_v1beta2 - - -async def sample_update_project_settings(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateProjectSettingsRequest( - ) - - # Make the request - response = await client.update_project_settings(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateProjectSettings_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_sync.py deleted file mode 100644 index ca9bac31cbec..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateProjectSettings -# 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_v1beta2_generated_ArtifactRegistry_UpdateProjectSettings_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_v1beta2 - - -def sample_update_project_settings(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateProjectSettingsRequest( - ) - - # Make the request - response = client.update_project_settings(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateProjectSettings_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_repository_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_repository_async.py deleted file mode 100644 index 025f3b8e548b..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_repository_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateRepository -# 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_v1beta2_generated_ArtifactRegistry_UpdateRepository_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_v1beta2 - - -async def sample_update_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateRepositoryRequest( - ) - - # Make the request - response = await client.update_repository(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateRepository_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_repository_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_repository_sync.py deleted file mode 100644 index 12e577e8ff1f..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_repository_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateRepository -# 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_v1beta2_generated_ArtifactRegistry_UpdateRepository_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_v1beta2 - - -def sample_update_repository(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateRepositoryRequest( - ) - - # Make the request - response = client.update_repository(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateRepository_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_tag_async.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_tag_async.py deleted file mode 100644 index 93468442e8f2..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_tag_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateTag -# 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_v1beta2_generated_ArtifactRegistry_UpdateTag_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_v1beta2 - - -async def sample_update_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryAsyncClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateTagRequest( - ) - - # Make the request - response = await client.update_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateTag_async] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_tag_sync.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_tag_sync.py deleted file mode 100644 index 1c064bfe33e8..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/artifactregistry_v1beta2_generated_artifact_registry_update_tag_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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 UpdateTag -# 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_v1beta2_generated_ArtifactRegistry_UpdateTag_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_v1beta2 - - -def sample_update_tag(): - # Create a client - client = artifactregistry_v1beta2.ArtifactRegistryClient() - - # Initialize request argument(s) - request = artifactregistry_v1beta2.UpdateTagRequest( - ) - - # Make the request - response = client.update_tag(request=request) - - # Handle the response - print(response) - -# [END artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateTag_sync] diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json deleted file mode 100644 index c22cba2a0008..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json +++ /dev/null @@ -1,4050 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.devtools.artifactregistry.v1beta2", - "version": "v1beta2" - } - ], - "language": "PYTHON", - "name": "google-cloud-artifact-registry", - "version": "0.1.0" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.create_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.CreateRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.CreateRepositoryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "repository", - "type": "google.cloud.artifactregistry_v1beta2.types.Repository" - }, - { - "name": "repository_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_repository" - }, - "description": "Sample for CreateRepository", - "file": "artifactregistry_v1beta2_generated_artifact_registry_create_repository_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_CreateRepository_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_create_repository_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.create_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.CreateRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.CreateRepositoryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "repository", - "type": "google.cloud.artifactregistry_v1beta2.types.Repository" - }, - { - "name": "repository_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_repository" - }, - "description": "Sample for CreateRepository", - "file": "artifactregistry_v1beta2_generated_artifact_registry_create_repository_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_CreateRepository_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_create_repository_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.create_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.CreateTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.CreateTagRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "tag", - "type": "google.cloud.artifactregistry_v1beta2.types.Tag" - }, - { - "name": "tag_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.artifactregistry_v1beta2.types.Tag", - "shortName": "create_tag" - }, - "description": "Sample for CreateTag", - "file": "artifactregistry_v1beta2_generated_artifact_registry_create_tag_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_CreateTag_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_v1beta2_generated_artifact_registry_create_tag_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.create_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.CreateTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "CreateTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.CreateTagRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "tag", - "type": "google.cloud.artifactregistry_v1beta2.types.Tag" - }, - { - "name": "tag_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.artifactregistry_v1beta2.types.Tag", - "shortName": "create_tag" - }, - "description": "Sample for CreateTag", - "file": "artifactregistry_v1beta2_generated_artifact_registry_create_tag_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_CreateTag_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_v1beta2_generated_artifact_registry_create_tag_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.delete_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.DeletePackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeletePackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.DeletePackageRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_package" - }, - "description": "Sample for DeletePackage", - "file": "artifactregistry_v1beta2_generated_artifact_registry_delete_package_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_DeletePackage_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_v1beta2_generated_artifact_registry_delete_package_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.delete_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.DeletePackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeletePackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.DeletePackageRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_package" - }, - "description": "Sample for DeletePackage", - "file": "artifactregistry_v1beta2_generated_artifact_registry_delete_package_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_DeletePackage_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_v1beta2_generated_artifact_registry_delete_package_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.delete_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.DeleteRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.DeleteRepositoryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_repository" - }, - "description": "Sample for DeleteRepository", - "file": "artifactregistry_v1beta2_generated_artifact_registry_delete_repository_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteRepository_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_delete_repository_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.delete_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.DeleteRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.DeleteRepositoryRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_repository" - }, - "description": "Sample for DeleteRepository", - "file": "artifactregistry_v1beta2_generated_artifact_registry_delete_repository_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteRepository_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_delete_repository_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.delete_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.DeleteTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.DeleteTagRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_tag" - }, - "description": "Sample for DeleteTag", - "file": "artifactregistry_v1beta2_generated_artifact_registry_delete_tag_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteTag_async", - "segments": [ - { - "end": 48, - "start": 27, - "type": "FULL" - }, - { - "end": 48, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_delete_tag_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.delete_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.DeleteTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.DeleteTagRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "shortName": "delete_tag" - }, - "description": "Sample for DeleteTag", - "file": "artifactregistry_v1beta2_generated_artifact_registry_delete_tag_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteTag_sync", - "segments": [ - { - "end": 48, - "start": 27, - "type": "FULL" - }, - { - "end": 48, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_delete_tag_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.delete_version", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.DeleteVersion", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteVersion" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.DeleteVersionRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_version" - }, - "description": "Sample for DeleteVersion", - "file": "artifactregistry_v1beta2_generated_artifact_registry_delete_version_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteVersion_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_v1beta2_generated_artifact_registry_delete_version_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.delete_version", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.DeleteVersion", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "DeleteVersion" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.DeleteVersionRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_version" - }, - "description": "Sample for DeleteVersion", - "file": "artifactregistry_v1beta2_generated_artifact_registry_delete_version_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_DeleteVersion_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_v1beta2_generated_artifact_registry_delete_version_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.get_file", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetFile", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetFile" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetFileRequest" - }, - { - "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_v1beta2.types.File", - "shortName": "get_file" - }, - "description": "Sample for GetFile", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_file_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetFile_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_v1beta2_generated_artifact_registry_get_file_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.get_file", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetFile", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetFile" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetFileRequest" - }, - { - "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_v1beta2.types.File", - "shortName": "get_file" - }, - "description": "Sample for GetFile", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_file_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetFile_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_v1beta2_generated_artifact_registry_get_file_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.get_iam_policy", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetIamPolicy", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetIamPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy" - }, - "description": "Sample for GetIamPolicy", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetIamPolicy_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.get_iam_policy", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetIamPolicy", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetIamPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy" - }, - "description": "Sample for GetIamPolicy", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetIamPolicy_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_get_iam_policy_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.get_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetPackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetPackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetPackageRequest" - }, - { - "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_v1beta2.types.Package", - "shortName": "get_package" - }, - "description": "Sample for GetPackage", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_package_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetPackage_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_v1beta2_generated_artifact_registry_get_package_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.get_package", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetPackage", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetPackage" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetPackageRequest" - }, - { - "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_v1beta2.types.Package", - "shortName": "get_package" - }, - "description": "Sample for GetPackage", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_package_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetPackage_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_v1beta2_generated_artifact_registry_get_package_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.get_project_settings", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetProjectSettings", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetProjectSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetProjectSettingsRequest" - }, - { - "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_v1beta2.types.ProjectSettings", - "shortName": "get_project_settings" - }, - "description": "Sample for GetProjectSettings", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetProjectSettings_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_v1beta2_generated_artifact_registry_get_project_settings_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.get_project_settings", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetProjectSettings", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetProjectSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetProjectSettingsRequest" - }, - { - "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_v1beta2.types.ProjectSettings", - "shortName": "get_project_settings" - }, - "description": "Sample for GetProjectSettings", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_project_settings_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetProjectSettings_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_v1beta2_generated_artifact_registry_get_project_settings_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.get_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetRepositoryRequest" - }, - { - "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_v1beta2.types.Repository", - "shortName": "get_repository" - }, - "description": "Sample for GetRepository", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_repository_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetRepository_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_v1beta2_generated_artifact_registry_get_repository_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.get_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetRepositoryRequest" - }, - { - "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_v1beta2.types.Repository", - "shortName": "get_repository" - }, - "description": "Sample for GetRepository", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_repository_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetRepository_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_v1beta2_generated_artifact_registry_get_repository_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.get_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetTagRequest" - }, - { - "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_v1beta2.types.Tag", - "shortName": "get_tag" - }, - "description": "Sample for GetTag", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_tag_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetTag_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_v1beta2_generated_artifact_registry_get_tag_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.get_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.GetTagRequest" - }, - { - "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_v1beta2.types.Tag", - "shortName": "get_tag" - }, - "description": "Sample for GetTag", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_tag_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_GetTag_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_v1beta2_generated_artifact_registry_get_tag_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.get_version", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetVersion", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetVersion" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.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_v1beta2.types.Version", - "shortName": "get_version" - }, - "description": "Sample for GetVersion", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_version_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_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_v1beta2_generated_artifact_registry_get_version_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.get_version", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.GetVersion", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "GetVersion" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.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_v1beta2.types.Version", - "shortName": "get_version" - }, - "description": "Sample for GetVersion", - "file": "artifactregistry_v1beta2_generated_artifact_registry_get_version_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_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_v1beta2_generated_artifact_registry_get_version_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.import_apt_artifacts", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ImportAptArtifacts", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ImportAptArtifacts" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.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_v1beta2_generated_artifact_registry_import_apt_artifacts_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_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_v1beta2_generated_artifact_registry_import_apt_artifacts_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.import_apt_artifacts", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ImportAptArtifacts", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ImportAptArtifacts" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.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_v1beta2_generated_artifact_registry_import_apt_artifacts_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_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_v1beta2_generated_artifact_registry_import_apt_artifacts_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.import_yum_artifacts", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ImportYumArtifacts", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ImportYumArtifacts" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.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_v1beta2_generated_artifact_registry_import_yum_artifacts_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_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_v1beta2_generated_artifact_registry_import_yum_artifacts_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.import_yum_artifacts", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ImportYumArtifacts", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ImportYumArtifacts" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.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_v1beta2_generated_artifact_registry_import_yum_artifacts_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_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_v1beta2_generated_artifact_registry_import_yum_artifacts_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.list_files", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListFiles", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListFiles" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.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_v1beta2.services.artifact_registry.pagers.ListFilesAsyncPager", - "shortName": "list_files" - }, - "description": "Sample for ListFiles", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_files_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListFiles_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_list_files_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.list_files", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListFiles", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListFiles" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.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_v1beta2.services.artifact_registry.pagers.ListFilesPager", - "shortName": "list_files" - }, - "description": "Sample for ListFiles", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_files_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListFiles_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_list_files_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.list_packages", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListPackages", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListPackages" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.ListPackagesRequest" - }, - { - "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_v1beta2.services.artifact_registry.pagers.ListPackagesAsyncPager", - "shortName": "list_packages" - }, - "description": "Sample for ListPackages", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_packages_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListPackages_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_list_packages_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.list_packages", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListPackages", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListPackages" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.ListPackagesRequest" - }, - { - "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_v1beta2.services.artifact_registry.pagers.ListPackagesPager", - "shortName": "list_packages" - }, - "description": "Sample for ListPackages", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_packages_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListPackages_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_list_packages_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.list_repositories", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListRepositories", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListRepositories" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.ListRepositoriesRequest" - }, - { - "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_v1beta2.services.artifact_registry.pagers.ListRepositoriesAsyncPager", - "shortName": "list_repositories" - }, - "description": "Sample for ListRepositories", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_repositories_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListRepositories_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_v1beta2_generated_artifact_registry_list_repositories_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.list_repositories", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListRepositories", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListRepositories" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.ListRepositoriesRequest" - }, - { - "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_v1beta2.services.artifact_registry.pagers.ListRepositoriesPager", - "shortName": "list_repositories" - }, - "description": "Sample for ListRepositories", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_repositories_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListRepositories_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_v1beta2_generated_artifact_registry_list_repositories_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.list_tags", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListTags", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListTags" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.ListTagsRequest" - }, - { - "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_v1beta2.services.artifact_registry.pagers.ListTagsAsyncPager", - "shortName": "list_tags" - }, - "description": "Sample for ListTags", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_tags_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListTags_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_list_tags_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.list_tags", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListTags", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListTags" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.ListTagsRequest" - }, - { - "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_v1beta2.services.artifact_registry.pagers.ListTagsPager", - "shortName": "list_tags" - }, - "description": "Sample for ListTags", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_tags_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListTags_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_list_tags_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.list_versions", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListVersions", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListVersions" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.ListVersionsRequest" - }, - { - "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_v1beta2.services.artifact_registry.pagers.ListVersionsAsyncPager", - "shortName": "list_versions" - }, - "description": "Sample for ListVersions", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_versions_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListVersions_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_list_versions_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.list_versions", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.ListVersions", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "ListVersions" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.ListVersionsRequest" - }, - { - "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_v1beta2.services.artifact_registry.pagers.ListVersionsPager", - "shortName": "list_versions" - }, - "description": "Sample for ListVersions", - "file": "artifactregistry_v1beta2_generated_artifact_registry_list_versions_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_ListVersions_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "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": 52, - "start": 48, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_list_versions_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.set_iam_policy", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.SetIamPolicy", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "SetIamPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "set_iam_policy" - }, - "description": "Sample for SetIamPolicy", - "file": "artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_SetIamPolicy_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.set_iam_policy", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.SetIamPolicy", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "SetIamPolicy" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "set_iam_policy" - }, - "description": "Sample for SetIamPolicy", - "file": "artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_SetIamPolicy_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 49, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 50, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_set_iam_policy_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.test_iam_permissions", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.TestIamPermissions", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "TestIamPermissions" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", - "shortName": "test_iam_permissions" - }, - "description": "Sample for TestIamPermissions", - "file": "artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_TestIamPermissions_async", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.test_iam_permissions", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.TestIamPermissions", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "TestIamPermissions" - }, - "parameters": [ - { - "name": "request", - "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", - "shortName": "test_iam_permissions" - }, - "description": "Sample for TestIamPermissions", - "file": "artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_TestIamPermissions_sync", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 41, - "start": 39, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 42, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "artifactregistry_v1beta2_generated_artifact_registry_test_iam_permissions_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.update_project_settings", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.UpdateProjectSettings", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateProjectSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.UpdateProjectSettingsRequest" - }, - { - "name": "project_settings", - "type": "google.cloud.artifactregistry_v1beta2.types.ProjectSettings" - }, - { - "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_v1beta2.types.ProjectSettings", - "shortName": "update_project_settings" - }, - "description": "Sample for UpdateProjectSettings", - "file": "artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateProjectSettings_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_v1beta2_generated_artifact_registry_update_project_settings_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.update_project_settings", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.UpdateProjectSettings", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateProjectSettings" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.UpdateProjectSettingsRequest" - }, - { - "name": "project_settings", - "type": "google.cloud.artifactregistry_v1beta2.types.ProjectSettings" - }, - { - "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_v1beta2.types.ProjectSettings", - "shortName": "update_project_settings" - }, - "description": "Sample for UpdateProjectSettings", - "file": "artifactregistry_v1beta2_generated_artifact_registry_update_project_settings_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateProjectSettings_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_v1beta2_generated_artifact_registry_update_project_settings_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.update_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.UpdateRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.UpdateRepositoryRequest" - }, - { - "name": "repository", - "type": "google.cloud.artifactregistry_v1beta2.types.Repository" - }, - { - "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_v1beta2.types.Repository", - "shortName": "update_repository" - }, - "description": "Sample for UpdateRepository", - "file": "artifactregistry_v1beta2_generated_artifact_registry_update_repository_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateRepository_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_v1beta2_generated_artifact_registry_update_repository_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.update_repository", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.UpdateRepository", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateRepository" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.UpdateRepositoryRequest" - }, - { - "name": "repository", - "type": "google.cloud.artifactregistry_v1beta2.types.Repository" - }, - { - "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_v1beta2.types.Repository", - "shortName": "update_repository" - }, - "description": "Sample for UpdateRepository", - "file": "artifactregistry_v1beta2_generated_artifact_registry_update_repository_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateRepository_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_v1beta2_generated_artifact_registry_update_repository_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient", - "shortName": "ArtifactRegistryAsyncClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.update_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.UpdateTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.UpdateTagRequest" - }, - { - "name": "tag", - "type": "google.cloud.artifactregistry_v1beta2.types.Tag" - }, - { - "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_v1beta2.types.Tag", - "shortName": "update_tag" - }, - "description": "Sample for UpdateTag", - "file": "artifactregistry_v1beta2_generated_artifact_registry_update_tag_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateTag_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_v1beta2_generated_artifact_registry_update_tag_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient", - "shortName": "ArtifactRegistryClient" - }, - "fullName": "google.cloud.artifactregistry_v1beta2.ArtifactRegistryClient.update_tag", - "method": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry.UpdateTag", - "service": { - "fullName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", - "shortName": "ArtifactRegistry" - }, - "shortName": "UpdateTag" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.artifactregistry_v1beta2.types.UpdateTagRequest" - }, - { - "name": "tag", - "type": "google.cloud.artifactregistry_v1beta2.types.Tag" - }, - { - "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_v1beta2.types.Tag", - "shortName": "update_tag" - }, - "description": "Sample for UpdateTag", - "file": "artifactregistry_v1beta2_generated_artifact_registry_update_tag_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1beta2_generated_ArtifactRegistry_UpdateTag_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_v1beta2_generated_artifact_registry_update_tag_sync.py" - } - ] -} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/scripts/fixup_artifactregistry_v1beta2_keywords.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/scripts/fixup_artifactregistry_v1beta2_keywords.py deleted file mode 100644 index 92193b697ec0..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/scripts/fixup_artifactregistry_v1beta2_keywords.py +++ /dev/null @@ -1,200 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class artifactregistryCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_repository': ('parent', 'repository_id', 'repository', ), - 'create_tag': ('parent', 'tag_id', 'tag', ), - 'delete_package': ('name', ), - 'delete_repository': ('name', ), - 'delete_tag': ('name', ), - 'delete_version': ('name', 'force', ), - 'get_file': ('name', ), - 'get_iam_policy': ('resource', 'options', ), - 'get_package': ('name', ), - 'get_project_settings': ('name', ), - 'get_repository': ('name', ), - 'get_tag': ('name', ), - 'get_version': ('name', 'view', ), - 'import_apt_artifacts': ('gcs_source', 'parent', ), - 'import_yum_artifacts': ('gcs_source', 'parent', ), - 'list_files': ('parent', 'filter', 'page_size', 'page_token', ), - 'list_packages': ('parent', 'page_size', 'page_token', ), - 'list_repositories': ('parent', 'page_size', 'page_token', ), - 'list_tags': ('parent', 'filter', 'page_size', 'page_token', ), - 'list_versions': ('parent', 'page_size', 'page_token', 'view', 'order_by', ), - 'set_iam_policy': ('resource', 'policy', 'update_mask', ), - 'test_iam_permissions': ('resource', 'permissions', ), - 'update_project_settings': ('project_settings', 'update_mask', ), - 'update_repository': ('repository', 'update_mask', ), - 'update_tag': ('tag', 'update_mask', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: a.keyword.value not in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=artifactregistryCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the artifactregistry client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/setup.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/setup.py deleted file mode 100644 index 3ad6e1d0e59d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/setup.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import io -import os -import re - -import setuptools # type: ignore - -package_root = os.path.abspath(os.path.dirname(__file__)) - -name = 'google-cloud-artifact-registry' - - -description = "Google Cloud Artifact Registry API client library" - -version = None - -with open(os.path.join(package_root, 'google/cloud/artifactregistry/gapic_version.py')) as fp: - version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read()) - assert (len(version_candidates) == 1) - version = version_candidates[0] - -if version[0] == "0": - release_status = "Development Status :: 4 - Beta" -else: - release_status = "Development Status :: 5 - Production/Stable" - -dependencies = [ - "google-api-core[grpc] >= 1.34.1, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", - # Exclude incompatible versions of `google-auth` - # See https://github.com/googleapis/google-cloud-python/issues/12364 - "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", - "proto-plus >= 1.22.3, <2.0.0dev", - "proto-plus >= 1.25.0, <2.0.0dev; python_version >= '3.13'", - "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", - "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", -] -extras = { -} -url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-artifact-registry" - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, "README.rst") -with io.open(readme_filename, encoding="utf-8") as readme_file: - readme = readme_file.read() - -packages = [ - package - for package in setuptools.find_namespace_packages() - if package.startswith("google") -] - -setuptools.setup( - name=name, - version=version, - description=description, - long_description=readme, - author="Google LLC", - author_email="googleapis-packages@google.com", - license="Apache 2.0", - url=url, - classifiers=[ - release_status, - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Operating System :: OS Independent", - "Topic :: Internet", - ], - platforms="Posix; MacOS X; Windows", - packages=packages, - python_requires=">=3.7", - install_requires=dependencies, - extras_require=extras, - include_package_data=True, - zip_safe=False, -) diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.10.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.10.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.11.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.11.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.12.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.12.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.13.txt b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.13.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.13.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.7.txt deleted file mode 100644 index a81fb6bcd05c..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.7.txt +++ /dev/null @@ -1,11 +0,0 @@ -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List all library dependencies and extras in this file. -# Pin the version to the lower bound. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", -# Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.34.1 -google-auth==2.14.1 -proto-plus==1.22.3 -protobuf==3.20.2 -grpc-google-iam-v1==0.12.4 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.8.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.8.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.9.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/testing/constraints-3.9.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/__init__.py deleted file mode 100644 index 7b3de3117f38..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/__init__.py deleted file mode 100644 index 7b3de3117f38..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/__init__.py deleted file mode 100644 index 7b3de3117f38..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/artifactregistry_v1beta2/__init__.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/artifactregistry_v1beta2/__init__.py deleted file mode 100644 index 7b3de3117f38..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/artifactregistry_v1beta2/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py b/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py deleted file mode 100644 index 03cb85a1bf71..000000000000 --- a/owl-bot-staging/google-cloud-artifact-registry/v1beta2/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py +++ /dev/null @@ -1,18176 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 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. -# -import os -# try/except added for compatibility with python < 3.8 -try: - from unittest import mock - from unittest.mock import AsyncMock # pragma: NO COVER -except ImportError: # pragma: NO COVER - import mock - -import grpc -from grpc.experimental import aio -from collections.abc import Iterable, AsyncIterable -from google.protobuf import json_format -import json -import math -import pytest -from google.api_core import api_core_version -from proto.marshal.rules.dates import DurationRule, TimestampRule -from proto.marshal.rules import wrappers -from requests import Response -from requests import Request, PreparedRequest -from requests.sessions import Session -from google.protobuf import json_format - -try: - from google.auth.aio import credentials as ga_credentials_async - HAS_GOOGLE_AUTH_AIO = True -except ImportError: # pragma: NO COVER - HAS_GOOGLE_AUTH_AIO = False - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.artifactregistry_v1beta2.services.artifact_registry import ArtifactRegistryAsyncClient -from google.cloud.artifactregistry_v1beta2.services.artifact_registry import ArtifactRegistryClient -from google.cloud.artifactregistry_v1beta2.services.artifact_registry import pagers -from google.cloud.artifactregistry_v1beta2.services.artifact_registry import transports -from google.cloud.artifactregistry_v1beta2.types import apt_artifact -from google.cloud.artifactregistry_v1beta2.types import file -from google.cloud.artifactregistry_v1beta2.types import package -from google.cloud.artifactregistry_v1beta2.types import repository -from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository -from google.cloud.artifactregistry_v1beta2.types import service -from google.cloud.artifactregistry_v1beta2.types import settings -from google.cloud.artifactregistry_v1beta2.types import tag -from google.cloud.artifactregistry_v1beta2.types import tag as gda_tag -from google.cloud.artifactregistry_v1beta2.types import version -from google.cloud.artifactregistry_v1beta2.types import yum_artifact -from google.cloud.location import locations_pb2 -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import options_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.longrunning import operations_pb2 # type: ignore -from google.oauth2 import service_account -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 -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import expr_pb2 # type: ignore -import google.auth - - -async def mock_async_gen(data, chunk_size=1): - for i in range(0, len(data)): # pragma: NO COVER - chunk = data[i : i + chunk_size] - yield chunk.encode("utf-8") - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - -# TODO: use async auth anon credentials by default once the minimum version of google-auth is upgraded. -# See related issue: https://github.com/googleapis/gapic-generator-python/issues/2107. -def async_anonymous_credentials(): - if HAS_GOOGLE_AUTH_AIO: - return ga_credentials_async.AnonymousCredentials() - return ga_credentials.AnonymousCredentials() - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - -# If default endpoint template is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint template so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint_template(client): - return "test.{UNIVERSE_DOMAIN}" if ("localhost" in client._DEFAULT_ENDPOINT_TEMPLATE) else client._DEFAULT_ENDPOINT_TEMPLATE - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert ArtifactRegistryClient._get_default_mtls_endpoint(None) is None - assert ArtifactRegistryClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert ArtifactRegistryClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert ArtifactRegistryClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert ArtifactRegistryClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert ArtifactRegistryClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - -def test__read_environment_variables(): - assert ArtifactRegistryClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - assert ArtifactRegistryClient._read_environment_variables() == (True, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - ArtifactRegistryClient._read_environment_variables() - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "never", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "always", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - ArtifactRegistryClient._read_environment_variables() - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - with mock.patch.dict(os.environ, {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": "foo.com"}): - assert ArtifactRegistryClient._read_environment_variables() == (False, "auto", "foo.com") - -def test__get_client_cert_source(): - mock_provided_cert_source = mock.Mock() - mock_default_cert_source = mock.Mock() - - assert ArtifactRegistryClient._get_client_cert_source(None, False) is None - assert ArtifactRegistryClient._get_client_cert_source(mock_provided_cert_source, False) is None - assert ArtifactRegistryClient._get_client_cert_source(mock_provided_cert_source, True) == mock_provided_cert_source - - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_default_cert_source): - assert ArtifactRegistryClient._get_client_cert_source(None, True) is mock_default_cert_source - assert ArtifactRegistryClient._get_client_cert_source(mock_provided_cert_source, "true") is mock_provided_cert_source - -@mock.patch.object(ArtifactRegistryClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryAsyncClient)) -def test__get_api_endpoint(): - api_override = "foo.com" - mock_client_cert_source = mock.Mock() - default_universe = ArtifactRegistryClient._DEFAULT_UNIVERSE - default_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) - mock_universe = "bar.com" - mock_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) - - assert ArtifactRegistryClient._get_api_endpoint(api_override, mock_client_cert_source, default_universe, "always") == api_override - assert ArtifactRegistryClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "auto") == ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - assert ArtifactRegistryClient._get_api_endpoint(None, None, default_universe, "auto") == default_endpoint - assert ArtifactRegistryClient._get_api_endpoint(None, None, default_universe, "always") == ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - assert ArtifactRegistryClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "always") == ArtifactRegistryClient.DEFAULT_MTLS_ENDPOINT - assert ArtifactRegistryClient._get_api_endpoint(None, None, mock_universe, "never") == mock_endpoint - assert ArtifactRegistryClient._get_api_endpoint(None, None, default_universe, "never") == default_endpoint - - with pytest.raises(MutualTLSChannelError) as excinfo: - ArtifactRegistryClient._get_api_endpoint(None, mock_client_cert_source, mock_universe, "auto") - assert str(excinfo.value) == "mTLS is not supported in any universe other than googleapis.com." - - -def test__get_universe_domain(): - client_universe_domain = "foo.com" - universe_domain_env = "bar.com" - - assert ArtifactRegistryClient._get_universe_domain(client_universe_domain, universe_domain_env) == client_universe_domain - assert ArtifactRegistryClient._get_universe_domain(None, universe_domain_env) == universe_domain_env - assert ArtifactRegistryClient._get_universe_domain(None, None) == ArtifactRegistryClient._DEFAULT_UNIVERSE - - with pytest.raises(ValueError) as excinfo: - ArtifactRegistryClient._get_universe_domain("", None) - assert str(excinfo.value) == "Universe Domain cannot be an empty string." - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest"), -]) -def test__validate_universe_domain(client_class, transport_class, transport_name): - client = client_class( - transport=transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) - ) - assert client._validate_universe_domain() == True - - # Test the case when universe is already validated. - assert client._validate_universe_domain() == True - - if transport_name == "grpc": - # Test the case where credentials are provided by the - # `local_channel_credentials`. The default universes in both match. - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - client = client_class(transport=transport_class(channel=channel)) - assert client._validate_universe_domain() == True - - # Test the case where credentials do not exist: e.g. a transport is provided - # with no credentials. Validation should still succeed because there is no - # mismatch with non-existent credentials. - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - transport=transport_class(channel=channel) - transport._credentials = None - client = client_class(transport=transport) - assert client._validate_universe_domain() == True - - # TODO: This is needed to cater for older versions of google-auth - # Make this test unconditional once the minimum supported version of - # google-auth becomes 2.23.0 or higher. - google_auth_major, google_auth_minor = [int(part) for part in google.auth.__version__.split(".")[0:2]] - if google_auth_major > 2 or (google_auth_major == 2 and google_auth_minor >= 23): - credentials = ga_credentials.AnonymousCredentials() - credentials._universe_domain = "foo.com" - # Test the case when there is a universe mismatch from the credentials. - client = client_class( - transport=transport_class(credentials=credentials) - ) - with pytest.raises(ValueError) as excinfo: - client._validate_universe_domain() - assert str(excinfo.value) == "The configured universe domain (googleapis.com) does not match the universe domain found in the credentials (foo.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default." - - # Test the case when there is a universe mismatch from the client. - # - # TODO: Make this test unconditional once the minimum supported version of - # google-api-core becomes 2.15.0 or higher. - api_core_major, api_core_minor = [int(part) for part in api_core_version.__version__.split(".")[0:2]] - if api_core_major > 2 or (api_core_major == 2 and api_core_minor >= 15): - client = client_class(client_options={"universe_domain": "bar.com"}, transport=transport_class(credentials=ga_credentials.AnonymousCredentials(),)) - with pytest.raises(ValueError) as excinfo: - client._validate_universe_domain() - assert str(excinfo.value) == "The configured universe domain (bar.com) does not match the universe domain found in the credentials (googleapis.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default." - - # Test that ValueError is raised if universe_domain is provided via client options and credentials is None - with pytest.raises(ValueError): - client._compare_universes("foo.bar", None) - - -@pytest.mark.parametrize("client_class,transport_name", [ - (ArtifactRegistryClient, "grpc"), - (ArtifactRegistryAsyncClient, "grpc_asyncio"), - (ArtifactRegistryClient, "rest"), -]) -def test_artifact_registry_client_from_service_account_info(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info, transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'artifactregistry.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://artifactregistry.googleapis.com' - ) - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.ArtifactRegistryGrpcTransport, "grpc"), - (transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio"), - (transports.ArtifactRegistryRestTransport, "rest"), -]) -def test_artifact_registry_client_service_account_always_use_jwt(transport_class, transport_name): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize("client_class,transport_name", [ - (ArtifactRegistryClient, "grpc"), - (ArtifactRegistryAsyncClient, "grpc_asyncio"), - (ArtifactRegistryClient, "rest"), -]) -def test_artifact_registry_client_from_service_account_file(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'artifactregistry.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://artifactregistry.googleapis.com' - ) - - -def test_artifact_registry_client_get_transport_class(): - transport = ArtifactRegistryClient.get_transport_class() - available_transports = [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryRestTransport, - ] - assert transport in available_transports - - transport = ArtifactRegistryClient.get_transport_class("grpc") - assert transport == transports.ArtifactRegistryGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc"), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest"), -]) -@mock.patch.object(ArtifactRegistryClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryAsyncClient)) -def test_artifact_registry_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(ArtifactRegistryClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(ArtifactRegistryClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - client = client_class(transport=transport_name) - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - client = client_class(transport=transport_name) - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - # Check the case api_endpoint is provided - options = client_options.ClientOptions(api_audience="https://language.googleapis.com") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience="https://language.googleapis.com" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc", "true"), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc", "false"), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio", "false"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest", "true"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest", "false"), -]) -@mock.patch.object(ArtifactRegistryClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_artifact_registry_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE) - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE) - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - ArtifactRegistryClient, ArtifactRegistryAsyncClient -]) -@mock.patch.object(ArtifactRegistryClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ArtifactRegistryAsyncClient)) -def test_artifact_registry_client_get_mtls_endpoint_and_cert_source(client_class): - mock_client_cert_source = mock.Mock() - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source == mock_client_cert_source - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - mock_client_cert_source = mock.Mock() - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_client_cert_source): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source == mock_client_cert_source - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - client_class.get_mtls_endpoint_and_cert_source() - - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - client_class.get_mtls_endpoint_and_cert_source() - - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - -@pytest.mark.parametrize("client_class", [ - ArtifactRegistryClient, ArtifactRegistryAsyncClient -]) -@mock.patch.object(ArtifactRegistryClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryClient)) -@mock.patch.object(ArtifactRegistryAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(ArtifactRegistryAsyncClient)) -def test_artifact_registry_client_client_api_endpoint(client_class): - mock_client_cert_source = client_cert_source_callback - api_override = "foo.com" - default_universe = ArtifactRegistryClient._DEFAULT_UNIVERSE - default_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) - mock_universe = "bar.com" - mock_endpoint = ArtifactRegistryClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) - - # If ClientOptions.api_endpoint is set and GOOGLE_API_USE_CLIENT_CERTIFICATE="true", - # use ClientOptions.api_endpoint as the api endpoint regardless. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"): - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=api_override) - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == api_override - - # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="never", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - client = client_class(credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == default_endpoint - - # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="always", - # use the DEFAULT_MTLS_ENDPOINT as the api endpoint. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - client = client_class(credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - - # If ClientOptions.api_endpoint is not set, GOOGLE_API_USE_MTLS_ENDPOINT="auto" (default), - # GOOGLE_API_USE_CLIENT_CERTIFICATE="false" (default), default cert source doesn't exist, - # and ClientOptions.universe_domain="bar.com", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with universe domain as the api endpoint. - options = client_options.ClientOptions() - universe_exists = hasattr(options, "universe_domain") - if universe_exists: - options = client_options.ClientOptions(universe_domain=mock_universe) - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - else: - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == (mock_endpoint if universe_exists else default_endpoint) - assert client.universe_domain == (mock_universe if universe_exists else default_universe) - - # If ClientOptions does not have a universe domain attribute and GOOGLE_API_USE_MTLS_ENDPOINT="never", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. - options = client_options.ClientOptions() - if hasattr(options, "universe_domain"): - delattr(options, "universe_domain") - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == default_endpoint - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc"), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio"), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest"), -]) -def test_artifact_registry_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc", grpc_helpers), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), - (ArtifactRegistryClient, transports.ArtifactRegistryRestTransport, "rest", None), -]) -def test_artifact_registry_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -def test_artifact_registry_client_client_options_from_dict(): - with mock.patch('google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.ArtifactRegistryGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = ArtifactRegistryClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport, "grpc", grpc_helpers), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_artifact_registry_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # test that the credentials from file are saved and used as the credentials. - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel" - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - file_creds = ga_credentials.AnonymousCredentials() - load_creds.return_value = (file_creds, None) - adc.return_value = (creds, None) - client = client_class(client_options=options, transport=transport_name) - create_channel.assert_called_with( - "artifactregistry.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', -), - scopes=None, - default_host="artifactregistry.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("request_type", [ - apt_artifact.ImportAptArtifactsRequest, - dict, -]) -def test_import_apt_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.import_apt_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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = apt_artifact.ImportAptArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_import_apt_artifacts_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = apt_artifact.ImportAptArtifactsRequest( - 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__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.import_apt_artifacts(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == apt_artifact.ImportAptArtifactsRequest( - parent='parent_value', - ) - -def test_import_apt_artifacts_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.import_apt_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.import_apt_artifacts] = mock_rpc - request = {} - client.import_apt_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_apt_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_import_apt_artifacts_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.import_apt_artifacts in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.import_apt_artifacts] = mock_rpc - - request = {} - await client.import_apt_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.import_apt_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_import_apt_artifacts_async(transport: str = 'grpc_asyncio', request_type=apt_artifact.ImportAptArtifactsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_apt_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') - ) - 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] - request = apt_artifact.ImportAptArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_import_apt_artifacts_async_from_dict(): - await test_import_apt_artifacts_async(request_type=dict) - -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 = 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.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 - _, 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_apt_artifacts_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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.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__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - 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] == 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.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.import_yum_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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = yum_artifact.ImportYumArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_import_yum_artifacts_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = yum_artifact.ImportYumArtifactsRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.import_yum_artifacts(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == yum_artifact.ImportYumArtifactsRequest( - parent='parent_value', - ) - -def test_import_yum_artifacts_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.import_yum_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.import_yum_artifacts] = mock_rpc - request = {} - client.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_yum_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_import_yum_artifacts_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.import_yum_artifacts in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.import_yum_artifacts] = mock_rpc - - request = {} - await client.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.import_yum_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_import_yum_artifacts_async(transport: str = 'grpc_asyncio', request_type=yum_artifact.ImportYumArtifactsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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__') 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.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = yum_artifact.ImportYumArtifactsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@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( - 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=async_anonymous_credentials(), - ) - - # 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 - - # 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, - ) - - # 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__') as call: - # Designate an appropriate return value for the call. - call.return_value = repository.ListRepositoriesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = repository.ListRepositoriesRequest() - assert args[0] == request - - # 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_repositories_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = repository.ListRepositoriesRequest( - parent='parent_value', - page_token='page_token_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_repositories(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == repository.ListRepositoriesRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_repositories_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_repositories in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_repositories] = mock_rpc - request = {} - client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_repositories(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_repositories_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_repositories in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_repositories] = mock_rpc - - request = {} - await client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_repositories(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_repositories_async(transport: str = 'grpc_asyncio', request_type=repository.ListRepositoriesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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__') 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', - )) - 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] - request = repository.ListRepositoriesRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = ( - 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_repositories(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, repository.Repository) - for i in results) -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_repositories), - '__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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_repositories(request={}) - ).pages: - 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', - ) - 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] - request = repository.GetRepositoryRequest() - assert args[0] == request - - # 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_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = repository.GetRepositoryRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_repository(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == repository.GetRepositoryRequest( - name='name_value', - ) - -def test_get_repository_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_repository] = mock_rpc - request = {} - client.get_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_repository_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_repository in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_repository] = mock_rpc - - request = {} - await client.get_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_repository_async(transport: str = 'grpc_asyncio', request_type=repository.GetRepositoryRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = repository.GetRepositoryRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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] - request = gda_repository.CreateRepositoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_repository_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_repository.CreateRepositoryRequest( - parent='parent_value', - repository_id='repository_id_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_repository(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.CreateRepositoryRequest( - parent='parent_value', - repository_id='repository_id_value', - ) - -def test_create_repository_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_repository] = mock_rpc - request = {} - client.create_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_repository_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_repository in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_repository] = mock_rpc - - request = {} - await client.create_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.create_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_repository_async(transport: str = 'grpc_asyncio', request_type=gda_repository.CreateRepositoryRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = gda_repository.CreateRepositoryRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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', - ) - 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] - request = gda_repository.UpdateRepositoryRequest() - assert args[0] == request - - # 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_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_repository.UpdateRepositoryRequest( - ) - - # 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_repository(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_repository.UpdateRepositoryRequest( - ) - -def test_update_repository_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_repository] = mock_rpc - request = {} - client.update_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_repository_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_repository in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_repository] = mock_rpc - - request = {} - await client.update_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_repository_async(transport: str = 'grpc_asyncio', request_type=gda_repository.UpdateRepositoryRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = gda_repository.UpdateRepositoryRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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] - request = repository.DeleteRepositoryRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_repository_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = repository.DeleteRepositoryRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_repository(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == repository.DeleteRepositoryRequest( - name='name_value', - ) - -def test_delete_repository_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_repository] = mock_rpc - request = {} - client.delete_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_repository_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_repository in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_repository] = mock_rpc - - request = {} - await client.delete_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_repository_async(transport: str = 'grpc_asyncio', request_type=repository.DeleteRepositoryRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = repository.DeleteRepositoryRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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] - request = package.ListPackagesRequest() - assert args[0] == request - - # 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_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = package.ListPackagesRequest( - parent='parent_value', - page_token='page_token_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_packages(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == package.ListPackagesRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_packages_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_packages] = mock_rpc - request = {} - client.list_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_packages_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_packages in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_packages] = mock_rpc - - request = {} - await client.list_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_packages_async(transport: str = 'grpc_asyncio', request_type=package.ListPackagesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = package.ListPackagesRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_packages(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_packages(request={}) - ).pages: - 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] - request = package.GetPackageRequest() - assert args[0] == request - - # 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_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = package.GetPackageRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_package(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == package.GetPackageRequest( - name='name_value', - ) - -def test_get_package_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_package] = mock_rpc - request = {} - client.get_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_package_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_package in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_package] = mock_rpc - - request = {} - await client.get_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_package_async(transport: str = 'grpc_asyncio', request_type=package.GetPackageRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = package.GetPackageRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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] - request = package.DeletePackageRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_package_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = package.DeletePackageRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_package(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == package.DeletePackageRequest( - name='name_value', - ) - -def test_delete_package_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_package] = mock_rpc - request = {} - client.delete_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_package_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_package in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_package] = mock_rpc - - request = {} - await client.delete_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_package_async(transport: str = 'grpc_asyncio', request_type=package.DeletePackageRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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] - request = package.DeletePackageRequest() - assert args[0] == request - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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_list_versions(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_versions), - '__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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = version.ListVersionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_versions_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = version.ListVersionsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_versions(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == version.ListVersionsRequest( - parent='parent_value', - page_token='page_token_value', - order_by='order_by_value', - ) - -def test_list_versions_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_versions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_versions] = mock_rpc - request = {} - client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_versions_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_versions in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_versions] = mock_rpc - - request = {} - await client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_versions_async(transport: str = 'grpc_asyncio', request_type=version.ListVersionsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_versions), - '__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', - )) - 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] - request = version.ListVersionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_versions_async_from_dict(): - await test_list_versions_async(request_type=dict) - -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 = version.ListVersionsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - call.return_value = version.ListVersionsResponse() - client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - 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_versions_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = version.ListVersionsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - call.return_value = 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) - _, 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_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.list_versions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = version.ListVersionsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_versions( - parent='parent_value', - ) - - # 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_versions_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_versions( - version.ListVersionsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_versions_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = version.ListVersionsResponse() - - call.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.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=async_anonymous_credentials(), - ) - - # 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_versions(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_versions(request={}) - ).pages: - 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, - dict, -]) -def test_get_version(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_version), - '__call__') as call: - # Designate an appropriate return value for the call. - 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] - request = version.GetVersionRequest() - assert args[0] == request - - # 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' - - -def test_get_version_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = version.GetVersionRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_version(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == version.GetVersionRequest( - name='name_value', - ) - -def test_get_version_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_version] = mock_rpc - request = {} - client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_version_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_version in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_version] = mock_rpc - - request = {} - await client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_version_async(transport: str = 'grpc_asyncio', request_type=version.GetVersionRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_version), - '__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', - )) - 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] - request = version.GetVersionRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_get_version_async_from_dict(): - await test_get_version_async(request_type=dict) - -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 = version.GetVersionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - call.return_value = version.Version() - client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - 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_version_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = version.GetVersionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.Version()) - await client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - 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_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.get_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = version.Version() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_version( - name='name_value', - ) - - # 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_version_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_version( - version.GetVersionRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_version_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = version.Version() - - call.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.get_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].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_version_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - version.DeleteVersionRequest, - dict, -]) -def test_delete_version(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_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = version.DeleteVersionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_version_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = version.DeleteVersionRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_version(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == version.DeleteVersionRequest( - name='name_value', - ) - -def test_delete_version_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_version] = mock_rpc - request = {} - client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_version_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_version in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_version] = mock_rpc - - request = {} - await client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_version_async(transport: str = 'grpc_asyncio', request_type=version.DeleteVersionRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_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') - ) - 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] - request = version.DeleteVersionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_version_async_from_dict(): - await test_delete_version_async(request_type=dict) - -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.DeleteVersionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - 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_version_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = version.DeleteVersionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - 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] == 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_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_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_version( - name='name_value', - ) - - # 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_version_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_version( - version.DeleteVersionRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_version_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.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_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].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_version_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - file.ListFilesRequest, - dict, -]) -def test_list_files(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_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = file.ListFilesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_files_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = file.ListFilesRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_files(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == file.ListFilesRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_value', - ) - -def test_list_files_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_files in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_files] = mock_rpc - request = {} - client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_files(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_files_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_files in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_files] = mock_rpc - - request = {} - await client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_files(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_files_async(transport: str = 'grpc_asyncio', request_type=file.ListFilesRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(file.ListFilesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = file.ListFilesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesAsyncPager) - 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) - -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 = file.ListFilesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - call.return_value = file.ListFilesResponse() - client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - 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_files_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = file.ListFilesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - call.return_value = 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) - _, 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_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.list_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_files( - parent='parent_value', - ) - - # 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_files_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_files( - file.ListFilesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_files_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.ListFilesResponse() - - call.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.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=async_anonymous_credentials(), - ) - - # 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_files(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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) - - assert len(responses) == 6 - assert all(isinstance(i, file.File) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_files_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_files(request={}) - ).pages: - 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", [ - file.GetFileRequest, - dict, -]) -def test_get_file(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_file), - '__call__') as call: - # Designate an appropriate return value for the call. - 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] - request = file.GetFileRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -def test_get_file_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = file.GetFileRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_file(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == file.GetFileRequest( - name='name_value', - ) - -def test_get_file_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_file in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_file] = mock_rpc - request = {} - client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_file_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_file in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_file] = mock_rpc - - request = {} - await client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_file_async(transport: str = 'grpc_asyncio', request_type=file.GetFileRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - )) - response = await client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = file.GetFileRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -@pytest.mark.asyncio -async def test_get_file_async_from_dict(): - await test_get_file_async(request_type=dict) - -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 = file.GetFileRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - call.return_value = file.File() - client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - 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_file_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = file.GetFileRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.File()) - await client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - 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_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.get_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.File() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_file( - name='name_value', - ) - - # 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_file_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_file( - file.GetFileRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_file_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = file.File() - - call.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.get_file( - 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_file_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - tag.ListTagsRequest, - dict, -]) -def test_list_tags(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_tags), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = tag.ListTagsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_tags_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = tag.ListTagsRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_tags(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tag.ListTagsRequest( - parent='parent_value', - filter='filter_value', - page_token='page_token_value', - ) - -def test_list_tags_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_tags in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_tags] = mock_rpc - request = {} - client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_tags(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_tags_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_tags in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_tags] = mock_rpc - - request = {} - await client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_tags(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_tags_async(transport: str = 'grpc_asyncio', request_type=tag.ListTagsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_tags), - '__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', - )) - 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] - request = tag.ListTagsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_tags_async_from_dict(): - await test_list_tags_async(request_type=dict) - -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 = tag.ListTagsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tags), - '__call__') as call: - call.return_value = tag.ListTagsResponse() - client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - 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_tags_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = tag.ListTagsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_tags), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.ListTagsResponse()) - 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] == 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_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_tags), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_tags( - parent='parent_value', - ) - - # 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_tags_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_tags( - tag.ListTagsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_tags_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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( - 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_tags_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_tags(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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={},) - 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) - - -@pytest.mark.asyncio -async def test_list_tags_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_tags(request={}) - ).pages: - 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, - dict, -]) -def test_get_tag(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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tag.Tag( - name='name_value', - version='version_value', - ) - response = client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = tag.GetTagRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) - assert response.name == 'name_value' - assert response.version == 'version_value' - - -def test_get_tag_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = tag.GetTagRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_tag(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tag.GetTagRequest( - name='name_value', - ) - -def test_get_tag_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_tag] = mock_rpc - request = {} - client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_tag in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_tag] = mock_rpc - - request = {} - await client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_tag_async(transport: str = 'grpc_asyncio', request_type=tag.GetTagRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag( - name='name_value', - version='version_value', - )) - response = await client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = tag.GetTagRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) - assert response.name == 'name_value' - assert response.version == 'version_value' - - -@pytest.mark.asyncio -async def test_get_tag_async_from_dict(): - await test_get_tag_async(request_type=dict) - -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 = tag.GetTagRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - call.return_value = tag.Tag() - client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_tag_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = tag.GetTagRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag()) - await client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_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: - # Designate an appropriate return value for the call. - call.return_value = tag.Tag() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_tag( - name='name_value', - ) - - # 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_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.get_tag( - tag.GetTagRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_tag_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = tag.Tag() - - call.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_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_get_tag_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_tag.CreateTagRequest, - dict, -]) -def test_create_tag(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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag( - name='name_value', - version='version_value', - ) - response = client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_tag.CreateTagRequest() - assert args[0] == request - - # 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' - - -def test_create_tag_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_tag.CreateTagRequest( - parent='parent_value', - tag_id='tag_id_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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_tag(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.CreateTagRequest( - parent='parent_value', - tag_id='tag_id_value', - ) - -def test_create_tag_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_tag] = mock_rpc - request = {} - client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_tag in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_tag] = mock_rpc - - request = {} - await client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.create_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_tag_async(transport: str = 'grpc_asyncio', request_type=gda_tag.CreateTagRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_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) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_tag.CreateTagRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_create_tag_async_from_dict(): - await test_create_tag_async(request_type=dict) - -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 = gda_tag.CreateTagRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tag), - '__call__') as call: - call.return_value = gda_tag.Tag() - client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_tag_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = gda_tag.CreateTagRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) - await client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_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: - # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_tag( - 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) == 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' - assert arg == mock_val - - -def test_create_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.create_tag( - gda_tag.CreateTagRequest(), - parent='parent_value', - tag=gda_tag.Tag(name='name_value'), - tag_id='tag_id_value', - ) - -@pytest.mark.asyncio -async def test_create_tag_flattened_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - # 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_create_tag_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - gda_tag.UpdateTagRequest, - dict, -]) -def test_update_tag(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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag( - name='name_value', - version='version_value', - ) - response = client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = gda_tag.UpdateTagRequest() - assert args[0] == request - - # 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' - - -def test_update_tag_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = gda_tag.UpdateTagRequest( - ) - - # 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_tag(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.UpdateTagRequest( - ) - -def test_update_tag_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_tag] = mock_rpc - request = {} - client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_tag in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_tag] = mock_rpc - - request = {} - await client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_tag_async(transport: str = 'grpc_asyncio', request_type=gda_tag.UpdateTagRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_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.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = gda_tag.UpdateTagRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_update_tag_async_from_dict(): - await test_update_tag_async(request_type=dict) - -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 = gda_tag.UpdateTagRequest() - - request.tag.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tag), - '__call__') as call: - call.return_value = gda_tag.Tag() - client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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', - 'tag.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_tag_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = gda_tag.UpdateTagRequest() - - request.tag.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) - await client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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', - '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=async_anonymous_credentials(), - ) - - # 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 - -@pytest.mark.asyncio -async def test_update_tag_flattened_error_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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']), - ) - - -@pytest.mark.parametrize("request_type", [ - tag.DeleteTagRequest, - dict, -]) -def test_delete_tag(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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = tag.DeleteTagRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_tag_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = tag.DeleteTagRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_tag(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == tag.DeleteTagRequest( - name='name_value', - ) - -def test_delete_tag_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_tag] = mock_rpc - request = {} - client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.delete_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_tag in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_tag] = mock_rpc - - request = {} - await client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.delete_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_tag_async(transport: str = 'grpc_asyncio', request_type=tag.DeleteTagRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = tag.DeleteTagRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_tag_async_from_dict(): - await test_delete_tag_async(request_type=dict) - -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 = tag.DeleteTagRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - call.return_value = None - client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_tag_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = tag.DeleteTagRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - 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_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(): - 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=async_anonymous_credentials(), - ) - - # 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.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=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.SetIamPolicyRequest, - dict, -]) -def test_set_iam_policy(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.set_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b'etag_blob', - ) - 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] - request = iam_policy_pb2.SetIamPolicyRequest() - assert args[0] == request - - # 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' - - -def test_set_iam_policy_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.SetIamPolicyRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.set_iam_policy(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.SetIamPolicyRequest( - resource='resource_value', - ) - -def test_set_iam_policy_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.set_iam_policy in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.set_iam_policy] = mock_rpc - request = {} - client.set_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.set_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_set_iam_policy_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.set_iam_policy in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.set_iam_policy] = mock_rpc - - request = {} - await client.set_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.set_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_set_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.SetIamPolicyRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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.set_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy( - version=774, - etag=b'etag_blob', - )) - 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] - request = iam_policy_pb2.SetIamPolicyRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_set_iam_policy_async_from_dict(): - await test_set_iam_policy_async(request_type=dict) - -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 = iam_policy_pb2.SetIamPolicyRequest() - - request.resource = 'resource_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy), - '__call__') as call: - call.return_value = policy_pb2.Policy() - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'resource=resource_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_set_iam_policy_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = iam_policy_pb2.SetIamPolicyRequest() - - request.resource = 'resource_value' - - # 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) - - # 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', - 'resource=resource_value', - ) in kw['metadata'] - -def test_set_iam_policy_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: - # 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", [ - iam_policy_pb2.GetIamPolicyRequest, - dict, -]) -def test_get_iam_policy(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_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b'etag_blob', - ) - 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] - request = iam_policy_pb2.GetIamPolicyRequest() - assert args[0] == request - - # 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' - - -def test_get_iam_policy_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.GetIamPolicyRequest( - resource='resource_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_iam_policy(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.GetIamPolicyRequest( - resource='resource_value', - ) - -def test_get_iam_policy_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_iam_policy in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_iam_policy] = mock_rpc - request = {} - client.get_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_iam_policy_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_iam_policy in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_iam_policy] = mock_rpc - - request = {} - await client.get_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.GetIamPolicyRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy( - version=774, - etag=b'etag_blob', - )) - 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] - request = iam_policy_pb2.GetIamPolicyRequest() - assert args[0] == request - - # 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' - - -@pytest.mark.asyncio -async def test_get_iam_policy_async_from_dict(): - await test_get_iam_policy_async(request_type=dict) - -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 = iam_policy_pb2.GetIamPolicyRequest() - - request.resource = 'resource_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy), - '__call__') as call: - call.return_value = policy_pb2.Policy() - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'resource=resource_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_iam_policy_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = iam_policy_pb2.GetIamPolicyRequest() - - request.resource = 'resource_value' - - # 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) - - # 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', - 'resource=resource_value', - ) in kw['metadata'] - -def test_get_iam_policy_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.get_iam_policy), - '__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.assert_called() - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.TestIamPermissionsRequest, - dict, -]) -def test_test_iam_permissions(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.test_iam_permissions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=['permissions_value'], - ) - response = client.test_iam_permissions(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.TestIamPermissionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ['permissions_value'] - - -def test_test_iam_permissions_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.TestIamPermissionsRequest( - resource='resource_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.test_iam_permissions(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.TestIamPermissionsRequest( - resource='resource_value', - ) - -def test_test_iam_permissions_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.test_iam_permissions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.test_iam_permissions] = mock_rpc - request = {} - client.test_iam_permissions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.test_iam_permissions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_test_iam_permissions_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.test_iam_permissions in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.test_iam_permissions] = mock_rpc - - request = {} - await client.test_iam_permissions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.test_iam_permissions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_test_iam_permissions_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.TestIamPermissionsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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.test_iam_permissions), - '__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'], - )) - 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] - request = iam_policy_pb2.TestIamPermissionsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ['permissions_value'] - - -@pytest.mark.asyncio -async def test_test_iam_permissions_async_from_dict(): - await test_test_iam_permissions_async(request_type=dict) - -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.TestIamPermissionsRequest() - - request.resource = 'resource_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), - '__call__') as call: - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'resource=resource_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_test_iam_permissions_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = iam_policy_pb2.TestIamPermissionsRequest() - - request.resource = 'resource_value' - - # 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 = 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) - _, 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', - 'resource=resource_value', - ) in kw['metadata'] - -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.test_iam_permissions), - '__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.assert_called() - - -@pytest.mark.parametrize("request_type", [ - settings.GetProjectSettingsRequest, - dict, -]) -def test_get_project_settings(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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - ) - 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] - request = settings.GetProjectSettingsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - 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_project_settings_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = settings.GetProjectSettingsRequest( - 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.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_project_settings(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == settings.GetProjectSettingsRequest( - name='name_value', - ) - -def test_get_project_settings_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_project_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_project_settings] = mock_rpc - request = {} - client.get_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_project_settings_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_project_settings in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_project_settings] = mock_rpc - - request = {} - await client.get_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_project_settings_async(transport: str = 'grpc_asyncio', request_type=settings.GetProjectSettingsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - )) - 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] - request = settings.GetProjectSettingsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - 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_project_settings_async_from_dict(): - await test_get_project_settings_async(request_type=dict) - -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 = settings.GetProjectSettingsRequest() - - 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) - - # 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_project_settings_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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.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 = 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) - _, 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_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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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', - ) - - -@pytest.mark.parametrize("request_type", [ - settings.UpdateProjectSettingsRequest, - dict, -]) -def test_update_project_settings(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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - ) - 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] - request = settings.UpdateProjectSettingsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - 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_update_project_settings_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = settings.UpdateProjectSettingsRequest( - ) - - # 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: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_project_settings(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == settings.UpdateProjectSettingsRequest( - ) - -def test_update_project_settings_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_project_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_project_settings] = mock_rpc - request = {} - client.update_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_project_settings_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_project_settings in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_project_settings] = mock_rpc - - request = {} - await client.update_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.update_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_project_settings_async(transport: str = 'grpc_asyncio', request_type=settings.UpdateProjectSettingsRequest): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - 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_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - )) - 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] - request = settings.UpdateProjectSettingsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - 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_update_project_settings_async_from_dict(): - await test_update_project_settings_async(request_type=dict) - -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 = settings.UpdateProjectSettingsRequest() - - 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.update_project_settings), - '__call__') as call: - 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 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'project_settings.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_project_settings_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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.project_settings.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__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings()) - 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] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'project_settings.name=name_value', - ) in kw['metadata'] - - -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.update_project_settings), - '__call__') as call: - # Designate an appropriate return value for the call. - 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=async_anonymous_credentials(), - ) - - # 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=async_anonymous_credentials(), - ) - - # 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']), - ) - - -def test_import_apt_artifacts_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.import_apt_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.import_apt_artifacts] = mock_rpc - - request = {} - client.import_apt_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_apt_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_import_yum_artifacts_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.import_yum_artifacts in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.import_yum_artifacts] = mock_rpc - - request = {} - client.import_yum_artifacts(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_yum_artifacts(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_repositories_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_repositories in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_repositories] = mock_rpc - - request = {} - client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_repositories(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_repositories_rest_required_fields(request_type=repository.ListRepositoriesRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_repositories._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_repositories._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_repositories(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_repositories_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_repositories._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_repositories_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_repositories(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{parent=projects/*/locations/*}/repositories" % client.transport._host, args[1]) - - -def test_list_repositories_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_repositories_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(repository.ListRepositoriesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_repositories(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, repository.Repository) - for i in results) - - pages = list(client.list_repositories(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_repository] = mock_rpc - - request = {} - client.get_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_repository_rest_required_fields(request_type=repository.GetRepositoryRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = repository.Repository() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_repository(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_repository_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_repository_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = repository.Repository() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*}" % client.transport._host, args[1]) - - -def test_get_repository_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_create_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_repository] = mock_rpc - - request = {} - client.create_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_repository_rest_required_fields(request_type=gda_repository.CreateRepositoryRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_repository._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("repository_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_repository(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_repository_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(("repositoryId", )) & set(("parent", ))) - - -def test_create_repository_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - repository=gda_repository.Repository(maven_config=gda_repository.Repository.MavenRepositoryConfig(allow_snapshot_overwrites=True)), - repository_id='repository_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{parent=projects/*/locations/*}/repositories" % client.transport._host, args[1]) - - -def test_create_repository_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_update_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_repository] = mock_rpc - - request = {} - client.update_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_repository_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_repository.Repository() - - # get arguments that satisfy an http rule for this method - sample_request = {'repository': {'name': 'projects/sample1/locations/sample2/repositories/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - repository=gda_repository.Repository(maven_config=gda_repository.Repository.MavenRepositoryConfig(allow_snapshot_overwrites=True)), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{repository.name=projects/*/locations/*/repositories/*}" % client.transport._host, args[1]) - - -def test_update_repository_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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']), - ) - - -def test_delete_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_repository] = mock_rpc - - request = {} - client.delete_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_repository_rest_required_fields(request_type=repository.DeleteRepositoryRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_repository(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_repository_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_repository_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*}" % client.transport._host, args[1]) - - -def test_delete_repository_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_packages_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_packages] = mock_rpc - - request = {} - client.list_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_packages_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = package.ListPackagesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = package.ListPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_packages(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{parent=projects/*/locations/*/repositories/*}/packages" % client.transport._host, args[1]) - - -def test_list_packages_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_packages_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(package.ListPackagesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_packages(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, package.Package) - for i in results) - - pages = list(client.list_packages(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_package_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_package] = mock_rpc - - request = {} - client.get_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_package_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = package.Package() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_package(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*}" % client.transport._host, args[1]) - - -def test_get_package_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_delete_package_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_package in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_package] = mock_rpc - - request = {} - client.delete_package(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_package(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_package_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_package(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*}" % client.transport._host, args[1]) - - -def test_delete_package_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_versions_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_versions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_versions] = mock_rpc - - request = {} - client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_versions_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = version.ListVersionsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = version.ListVersionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_versions(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{parent=projects/*/locations/*/repositories/*/packages/*}/versions" % client.transport._host, args[1]) - - -def test_list_versions_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_versions_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(version.ListVersionsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - pager = client.list_versions(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, version.Version) - for i in results) - - pages = list(client.list_versions(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_version_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_version] = mock_rpc - - request = {} - client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_version_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = version.Version() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = version.Version.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_version(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}" % client.transport._host, args[1]) - - -def test_get_version_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_delete_version_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_version] = mock_rpc - - request = {} - client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_version_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_version(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}" % client.transport._host, args[1]) - - -def test_delete_version_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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(), - name='name_value', - ) - - -def test_list_files_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_files in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_files] = mock_rpc - - request = {} - client.list_files(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_files(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_files_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = file.ListFilesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = file.ListFilesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_files(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{parent=projects/*/locations/*/repositories/*}/files" % client.transport._host, args[1]) - - -def test_list_files_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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(), - parent='parent_value', - ) - - -def test_list_files_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(file.ListFilesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - - pager = client.list_files(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, file.File) - for i in results) - - pages = list(client.list_files(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_file_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_file in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_file] = mock_rpc - - request = {} - client.get_file(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_file(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_file_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = file.File() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = file.File.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_file(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*/files/**}" % client.transport._host, args[1]) - - -def test_get_file_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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(), - name='name_value', - ) - - -def test_list_tags_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_tags in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_tags] = mock_rpc - - request = {} - client.list_tags(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_tags(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_tags_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = tag.ListTagsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = tag.ListTagsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_tags(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{parent=projects/*/locations/*/repositories/*/packages/*}/tags" % client.transport._host, args[1]) - - -def test_list_tags_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_list_tags_rest_pager(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(tag.ListTagsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - pager = client.list_tags(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, tag.Tag) - for i in results) - - pages = list(client.list_tags(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_tag] = mock_rpc - - request = {} - client.get_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = tag.Tag() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_tag(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}" % client.transport._host, args[1]) - - -def test_get_tag_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_create_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_tag] = mock_rpc - - request = {} - client.create_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - tag=gda_tag.Tag(name='name_value'), - tag_id='tag_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_tag(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{parent=projects/*/locations/*/repositories/*/packages/*}/tags" % client.transport._host, args[1]) - - -def test_create_tag_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_update_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_tag] = mock_rpc - - request = {} - client.update_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag() - - # get arguments that satisfy an http rule for this method - sample_request = {'tag': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'}} - - # get truthy value for each flattened field - mock_args = dict( - tag=gda_tag.Tag(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_tag(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{tag.name=projects/*/locations/*/repositories/*/packages/*/tags/*}" % client.transport._host, args[1]) - - -def test_update_tag_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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']), - ) - - -def test_delete_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_tag in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_tag] = mock_rpc - - request = {} - client.delete_tag(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.delete_tag(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_tag(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}" % client.transport._host, args[1]) - - -def test_delete_tag_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_set_iam_policy_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.set_iam_policy in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.set_iam_policy] = mock_rpc - - request = {} - client.set_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.set_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_set_iam_policy_rest_required_fields(request_type=iam_policy_pb2.SetIamPolicyRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["resource"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).set_iam_policy._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = 'resource_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).set_iam_policy._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == 'resource_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.set_iam_policy(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_set_iam_policy_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.set_iam_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("resource", "policy", ))) - - -def test_get_iam_policy_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_iam_policy in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_iam_policy] = mock_rpc - - request = {} - client.get_iam_policy(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_iam_policy(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_iam_policy_rest_required_fields(request_type=iam_policy_pb2.GetIamPolicyRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["resource"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_iam_policy._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = 'resource_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_iam_policy._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("options", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == 'resource_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_iam_policy(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_iam_policy_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_iam_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(("options", )) & set(("resource", ))) - - -def test_test_iam_permissions_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.test_iam_permissions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.test_iam_permissions] = mock_rpc - - request = {} - client.test_iam_permissions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.test_iam_permissions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_test_iam_permissions_rest_required_fields(request_type=iam_policy_pb2.TestIamPermissionsRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["resource"] = "" - request_init["permissions"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).test_iam_permissions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = 'resource_value' - jsonified_request["permissions"] = 'permissions_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).test_iam_permissions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == 'resource_value' - assert "permissions" in jsonified_request - assert jsonified_request["permissions"] == 'permissions_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.test_iam_permissions(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_test_iam_permissions_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.test_iam_permissions._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("resource", "permissions", ))) - - -def test_get_project_settings_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_project_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_project_settings] = mock_rpc - - request = {} - client.get_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_project_settings_rest_required_fields(request_type=settings.GetProjectSettingsRequest): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_project_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_project_settings._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_project_settings(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_project_settings_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_project_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_project_settings_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/projectSettings'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_project_settings(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{name=projects/*/projectSettings}" % client.transport._host, args[1]) - - -def test_get_project_settings_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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', - ) - - -def test_update_project_settings_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_project_settings in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_project_settings] = mock_rpc - - request = {} - client.update_project_settings(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.update_project_settings(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_project_settings_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() - - # get arguments that satisfy an http rule for this method - sample_request = {'project_settings': {'name': 'projects/sample1/projectSettings'}} - - # get truthy value for each flattened field - mock_args = dict( - project_settings=settings.ProjectSettings(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_project_settings(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1beta2/{project_settings.name=projects/*/projectSettings}" % client.transport._host, args[1]) - - -def test_update_project_settings_rest_flattened_error(transport: str = 'rest'): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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']), - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = ArtifactRegistryClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.ArtifactRegistryGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryGrpcAsyncIOTransport, - transports.ArtifactRegistryRestTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -def test_transport_kind_grpc(): - transport = ArtifactRegistryClient.get_transport_class("grpc")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" - - -def test_initialize_client_w_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc" - ) - assert client is not None - - -# 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_import_apt_artifacts_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = apt_artifact.ImportAptArtifactsRequest() - - assert args[0] == request_msg - - -# 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_import_yum_artifacts_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = yum_artifact.ImportYumArtifactsRequest() - - assert args[0] == request_msg - - -# 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_repositories_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.ListRepositoriesRequest() - - assert args[0] == request_msg - - -# 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_get_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.GetRepositoryRequest() - - assert args[0] == request_msg - - -# 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_create_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.CreateRepositoryRequest() - - assert args[0] == request_msg - - -# 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_update_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.UpdateRepositoryRequest() - - assert args[0] == request_msg - - -# 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_delete_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.DeleteRepositoryRequest() - - assert args[0] == request_msg - - -# 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_packages_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.ListPackagesRequest() - - assert args[0] == request_msg - - -# 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_get_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.GetPackageRequest() - - assert args[0] == request_msg - - -# 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_delete_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.DeletePackageRequest() - - assert args[0] == request_msg - - -# 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_versions_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.ListVersionsRequest() - - assert args[0] == request_msg - - -# 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_get_version_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.GetVersionRequest() - - assert args[0] == request_msg - - -# 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_delete_version_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.DeleteVersionRequest() - - assert args[0] == request_msg - - -# 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_files_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.ListFilesRequest() - - assert args[0] == request_msg - - -# 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_get_file_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.GetFileRequest() - - assert args[0] == request_msg - - -# 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_tags_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.ListTagsRequest() - - assert args[0] == request_msg - - -# 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_get_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.GetTagRequest() - - assert args[0] == request_msg - - -# 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_create_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.CreateTagRequest() - - assert args[0] == request_msg - - -# 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_update_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.UpdateTagRequest() - - assert args[0] == request_msg - - -# 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_delete_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - call.return_value = None - client.delete_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.DeleteTagRequest() - - assert args[0] == request_msg - - -# 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_set_iam_policy_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() - - assert args[0] == request_msg - - -# 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_get_iam_policy_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() - - assert args[0] == request_msg - - -# 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_test_iam_permissions_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() - - assert args[0] == request_msg - - -# 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_get_project_settings_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.GetProjectSettingsRequest() - - assert args[0] == request_msg - - -# 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_update_project_settings_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_project_settings), - '__call__') as call: - call.return_value = settings.ProjectSettings() - client.update_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.UpdateProjectSettingsRequest() - - assert args[0] == request_msg - - -def test_transport_kind_grpc_asyncio(): - transport = ArtifactRegistryAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" - - -def test_initialize_client_w_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_import_apt_artifacts_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - 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( - operations_pb2.Operation(name='operations/spam') - ) - await client.import_apt_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = apt_artifact.ImportAptArtifactsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_import_yum_artifacts_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.import_yum_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') - ) - await client.import_yum_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = yum_artifact.ImportYumArtifactsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_repositories_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(repository.ListRepositoriesResponse( - next_page_token='next_page_token_value', - )) - await client.list_repositories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.ListRepositoriesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - )) - await client.get_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.GetRepositoryRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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') - ) - await client.create_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.CreateRepositoryRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - )) - await client.update_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.UpdateRepositoryRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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') - ) - await client.delete_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.DeleteRepositoryRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_packages_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - )) - await client.list_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.ListPackagesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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', - )) - await client.get_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.GetPackageRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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') - ) - await client.delete_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.DeletePackageRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_versions_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.ListVersionsResponse( - next_page_token='next_page_token_value', - )) - await client.list_versions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.ListVersionsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_version_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.Version( - name='name_value', - description='description_value', - )) - await client.get_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.GetVersionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_version_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.delete_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.DeleteVersionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_files_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.ListFilesResponse( - next_page_token='next_page_token_value', - )) - await client.list_files(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.ListFilesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_file_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - )) - await client.get_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.GetFileRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_tags_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(tag.ListTagsResponse( - next_page_token='next_page_token_value', - )) - await client.list_tags(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.ListTagsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag( - name='name_value', - version='version_value', - )) - await client.get_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.GetTagRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag( - name='name_value', - version='version_value', - )) - await client.create_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.CreateTagRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag( - name='name_value', - version='version_value', - )) - await client.update_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.UpdateTagRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.DeleteTagRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_set_iam_policy_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy( - version=774, - etag=b'etag_blob', - )) - await client.set_iam_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_iam_policy_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy( - version=774, - etag=b'etag_blob', - )) - await client.get_iam_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_test_iam_permissions_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(iam_policy_pb2.TestIamPermissionsResponse( - permissions=['permissions_value'], - )) - await client.test_iam_permissions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_project_settings_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - )) - await client.get_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.GetProjectSettingsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_project_settings_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - )) - await client.update_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.UpdateProjectSettingsRequest() - - assert args[0] == request_msg - - -def test_transport_kind_rest(): - transport = ArtifactRegistryClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" - - -def test_import_apt_artifacts_rest_bad_request(request_type=apt_artifact.ImportAptArtifactsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.import_apt_artifacts(request) - - -@pytest.mark.parametrize("request_type", [ - apt_artifact.ImportAptArtifactsRequest, - dict, -]) -def test_import_apt_artifacts_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.import_apt_artifacts(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_import_apt_artifacts_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_import_apt_artifacts") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_import_apt_artifacts") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = apt_artifact.ImportAptArtifactsRequest.pb(apt_artifact.ImportAptArtifactsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = apt_artifact.ImportAptArtifactsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.import_apt_artifacts(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_import_yum_artifacts_rest_bad_request(request_type=yum_artifact.ImportYumArtifactsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.import_yum_artifacts(request) - - -@pytest.mark.parametrize("request_type", [ - yum_artifact.ImportYumArtifactsRequest, - dict, -]) -def test_import_yum_artifacts_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.import_yum_artifacts(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_import_yum_artifacts_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_import_yum_artifacts") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_import_yum_artifacts") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = yum_artifact.ImportYumArtifactsRequest.pb(yum_artifact.ImportYumArtifactsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = yum_artifact.ImportYumArtifactsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.import_yum_artifacts(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_repositories_rest_bad_request(request_type=repository.ListRepositoriesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_repositories(request) - - -@pytest.mark.parametrize("request_type", [ - repository.ListRepositoriesRequest, - dict, -]) -def test_list_repositories_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_repositories(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRepositoriesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_repositories_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_repositories") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_repositories") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = repository.ListRepositoriesRequest.pb(repository.ListRepositoriesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = repository.ListRepositoriesResponse.to_json(repository.ListRepositoriesResponse()) - req.return_value.content = return_value - - request = repository.ListRepositoriesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = repository.ListRepositoriesResponse() - - client.list_repositories(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_repository_rest_bad_request(request_type=repository.GetRepositoryRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_repository(request) - - -@pytest.mark.parametrize("request_type", [ - repository.GetRepositoryRequest, - dict, -]) -def test_get_repository_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = repository.Repository( - name='name_value', - format_=repository.Repository.Format.DOCKER, - description='description_value', - kms_key_name='kms_key_name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_repository(request) - - # 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.parametrize("null_interceptor", [True, False]) -def test_get_repository_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_repository") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_repository") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = repository.GetRepositoryRequest.pb(repository.GetRepositoryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = repository.Repository.to_json(repository.Repository()) - req.return_value.content = return_value - - request = repository.GetRepositoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = repository.Repository() - - client.get_repository(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_repository_rest_bad_request(request_type=gda_repository.CreateRepositoryRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.create_repository(request) - - -@pytest.mark.parametrize("request_type", [ - gda_repository.CreateRepositoryRequest, - dict, -]) -def test_create_repository_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["repository"] = {'maven_config': {'allow_snapshot_overwrites': True, 'version_policy': 1}, 'name': 'name_value', 'format_': 1, 'description': 'description_value', 'labels': {}, 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'kms_key_name': 'kms_key_name_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_repository.CreateRepositoryRequest.meta.fields["repository"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["repository"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["repository"][field])): - del request_init["repository"][field][i][subfield] - else: - del request_init["repository"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_repository(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_repository_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_create_repository") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_create_repository") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_repository.CreateRepositoryRequest.pb(gda_repository.CreateRepositoryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = gda_repository.CreateRepositoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.create_repository(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_repository_rest_bad_request(request_type=gda_repository.UpdateRepositoryRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'repository': {'name': 'projects/sample1/locations/sample2/repositories/sample3'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_repository(request) - - -@pytest.mark.parametrize("request_type", [ - gda_repository.UpdateRepositoryRequest, - dict, -]) -def test_update_repository_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'repository': {'name': 'projects/sample1/locations/sample2/repositories/sample3'}} - request_init["repository"] = {'maven_config': {'allow_snapshot_overwrites': True, 'version_policy': 1}, 'name': 'projects/sample1/locations/sample2/repositories/sample3', 'format_': 1, 'description': 'description_value', 'labels': {}, 'create_time': {'seconds': 751, 'nanos': 543}, 'update_time': {}, 'kms_key_name': 'kms_key_name_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_repository.UpdateRepositoryRequest.meta.fields["repository"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["repository"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["repository"][field])): - del request_init["repository"][field][i][subfield] - else: - del request_init["repository"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_repository.Repository( - name='name_value', - format_=gda_repository.Repository.Format.DOCKER, - description='description_value', - kms_key_name='kms_key_name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_repository(request) - - # 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.parametrize("null_interceptor", [True, False]) -def test_update_repository_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_repository") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_repository") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_repository.UpdateRepositoryRequest.pb(gda_repository.UpdateRepositoryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_repository.Repository.to_json(gda_repository.Repository()) - req.return_value.content = return_value - - request = gda_repository.UpdateRepositoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_repository.Repository() - - client.update_repository(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_repository_rest_bad_request(request_type=repository.DeleteRepositoryRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_repository(request) - - -@pytest.mark.parametrize("request_type", [ - repository.DeleteRepositoryRequest, - dict, -]) -def test_delete_repository_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_repository(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_repository_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_delete_repository") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_repository") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = repository.DeleteRepositoryRequest.pb(repository.DeleteRepositoryRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = repository.DeleteRepositoryRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_repository(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_packages_rest_bad_request(request_type=package.ListPackagesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_packages(request) - - -@pytest.mark.parametrize("request_type", [ - package.ListPackagesRequest, - dict, -]) -def test_list_packages_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = package.ListPackagesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = package.ListPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_packages(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPackagesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_packages_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_packages") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_packages") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = package.ListPackagesRequest.pb(package.ListPackagesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = package.ListPackagesResponse.to_json(package.ListPackagesResponse()) - req.return_value.content = return_value - - request = package.ListPackagesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = package.ListPackagesResponse() - - client.list_packages(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_package_rest_bad_request(request_type=package.GetPackageRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_package(request) - - -@pytest.mark.parametrize("request_type", [ - package.GetPackageRequest, - dict, -]) -def test_get_package_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = package.Package( - name='name_value', - display_name='display_name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_package(request) - - # 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.parametrize("null_interceptor", [True, False]) -def test_get_package_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_package") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_package") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = package.GetPackageRequest.pb(package.GetPackageRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = package.Package.to_json(package.Package()) - req.return_value.content = return_value - - request = package.GetPackageRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = package.Package() - - client.get_package(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_package_rest_bad_request(request_type=package.DeletePackageRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_package(request) - - -@pytest.mark.parametrize("request_type", [ - package.DeletePackageRequest, - dict, -]) -def test_delete_package_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_package(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_package_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_delete_package") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_package") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = package.DeletePackageRequest.pb(package.DeletePackageRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = package.DeletePackageRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_package(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_versions(request) - - -@pytest.mark.parametrize("request_type", [ - version.ListVersionsRequest, - dict, -]) -def test_list_versions_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = version.ListVersionsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = version.ListVersionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_versions(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVersionsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_versions_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_versions") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_versions") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = version.ListVersionsRequest.pb(version.ListVersionsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = version.ListVersionsResponse.to_json(version.ListVersionsResponse()) - req.return_value.content = return_value - - request = version.ListVersionsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = version.ListVersionsResponse() - - client.list_versions(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_version(request) - - -@pytest.mark.parametrize("request_type", [ - version.GetVersionRequest, - dict, -]) -def test_get_version_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = version.Version( - name='name_value', - description='description_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = version.Version.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_version(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_version_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_version") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_version") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = version.GetVersionRequest.pb(version.GetVersionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = version.Version.to_json(version.Version()) - req.return_value.content = return_value - - request = version.GetVersionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = version.Version() - - client.get_version(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_version_rest_bad_request(request_type=version.DeleteVersionRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_version(request) - - -@pytest.mark.parametrize("request_type", [ - version.DeleteVersionRequest, - dict, -]) -def test_delete_version_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_version(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_version_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_delete_version") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_version") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = version.DeleteVersionRequest.pb(version.DeleteVersionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = version.DeleteVersionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - - client.delete_version(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_files_rest_bad_request(request_type=file.ListFilesRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_files(request) - - -@pytest.mark.parametrize("request_type", [ - file.ListFilesRequest, - dict, -]) -def test_list_files_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = file.ListFilesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = file.ListFilesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_files(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_files_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_files") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_files") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = file.ListFilesRequest.pb(file.ListFilesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = file.ListFilesResponse.to_json(file.ListFilesResponse()) - req.return_value.content = return_value - - request = file.ListFilesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = file.ListFilesResponse() - - client.list_files(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_file_rest_bad_request(request_type=file.GetFileRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_file(request) - - -@pytest.mark.parametrize("request_type", [ - file.GetFileRequest, - dict, -]) -def test_get_file_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/files/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = file.File( - name='name_value', - size_bytes=1089, - owner='owner_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = file.File.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_file(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, file.File) - assert response.name == 'name_value' - assert response.size_bytes == 1089 - assert response.owner == 'owner_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_file_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_file") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_file") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = file.GetFileRequest.pb(file.GetFileRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = file.File.to_json(file.File()) - req.return_value.content = return_value - - request = file.GetFileRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = file.File() - - client.get_file(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_tags_rest_bad_request(request_type=tag.ListTagsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.list_tags(request) - - -@pytest.mark.parametrize("request_type", [ - tag.ListTagsRequest, - dict, -]) -def test_list_tags_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = tag.ListTagsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = tag.ListTagsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_tags(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTagsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_tags_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_list_tags") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_list_tags") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = tag.ListTagsRequest.pb(tag.ListTagsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = tag.ListTagsResponse.to_json(tag.ListTagsResponse()) - req.return_value.content = return_value - - request = tag.ListTagsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = tag.ListTagsResponse() - - client.list_tags(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_tag_rest_bad_request(request_type=tag.GetTagRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_tag(request) - - -@pytest.mark.parametrize("request_type", [ - tag.GetTagRequest, - dict, -]) -def test_get_tag_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = tag.Tag( - name='name_value', - version='version_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_tag(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) - assert response.name == 'name_value' - assert response.version == 'version_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_tag_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_tag") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_tag") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = tag.GetTagRequest.pb(tag.GetTagRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = tag.Tag.to_json(tag.Tag()) - req.return_value.content = return_value - - request = tag.GetTagRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = tag.Tag() - - client.get_tag(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_tag_rest_bad_request(request_type=gda_tag.CreateTagRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.create_tag(request) - - -@pytest.mark.parametrize("request_type", [ - gda_tag.CreateTagRequest, - dict, -]) -def test_create_tag_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4'} - request_init["tag"] = {'name': 'name_value', 'version': 'version_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_tag.CreateTagRequest.meta.fields["tag"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["tag"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["tag"][field])): - del request_init["tag"][field][i][subfield] - else: - del request_init["tag"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag( - name='name_value', - version='version_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_tag(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_tag_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_create_tag") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_create_tag") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_tag.CreateTagRequest.pb(gda_tag.CreateTagRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_tag.Tag.to_json(gda_tag.Tag()) - req.return_value.content = return_value - - request = gda_tag.CreateTagRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_tag.Tag() - - client.create_tag(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_tag_rest_bad_request(request_type=gda_tag.UpdateTagRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'tag': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_tag(request) - - -@pytest.mark.parametrize("request_type", [ - gda_tag.UpdateTagRequest, - dict, -]) -def test_update_tag_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'tag': {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'}} - request_init["tag"] = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5', 'version': 'version_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_tag.UpdateTagRequest.meta.fields["tag"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["tag"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["tag"][field])): - del request_init["tag"][field][i][subfield] - else: - del request_init["tag"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag( - name='name_value', - version='version_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_tag(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_tag_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_tag") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_tag") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = gda_tag.UpdateTagRequest.pb(gda_tag.UpdateTagRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = gda_tag.Tag.to_json(gda_tag.Tag()) - req.return_value.content = return_value - - request = gda_tag.UpdateTagRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = gda_tag.Tag() - - client.update_tag(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_delete_tag_rest_bad_request(request_type=tag.DeleteTagRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.delete_tag(request) - - -@pytest.mark.parametrize("request_type", [ - tag.DeleteTagRequest, - dict, -]) -def test_delete_tag_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = '' - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_tag(request) - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_tag_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_delete_tag") as pre: - pre.assert_not_called() - pb_message = tag.DeleteTagRequest.pb(tag.DeleteTagRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - - request = tag.DeleteTagRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_tag(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_set_iam_policy_rest_bad_request(request_type=iam_policy_pb2.SetIamPolicyRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.set_iam_policy(request) - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.SetIamPolicyRequest, - dict, -]) -def test_set_iam_policy_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy( - version=774, - etag=b'etag_blob', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.set_iam_policy(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_iam_policy_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_set_iam_policy") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_set_iam_policy") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = iam_policy_pb2.SetIamPolicyRequest() - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(policy_pb2.Policy()) - req.return_value.content = return_value - - request = iam_policy_pb2.SetIamPolicyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = policy_pb2.Policy() - - client.set_iam_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_iam_policy_rest_bad_request(request_type=iam_policy_pb2.GetIamPolicyRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_iam_policy(request) - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.GetIamPolicyRequest, - dict, -]) -def test_get_iam_policy_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy( - version=774, - etag=b'etag_blob', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_iam_policy(request) - - # 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' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_iam_policy_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_iam_policy") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_iam_policy") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = iam_policy_pb2.GetIamPolicyRequest() - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(policy_pb2.Policy()) - req.return_value.content = return_value - - request = iam_policy_pb2.GetIamPolicyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = policy_pb2.Policy() - - client.get_iam_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_test_iam_permissions_rest_bad_request(request_type=iam_policy_pb2.TestIamPermissionsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.test_iam_permissions(request) - - -@pytest.mark.parametrize("request_type", [ - iam_policy_pb2.TestIamPermissionsRequest, - dict, -]) -def test_test_iam_permissions_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'resource': 'projects/sample1/locations/sample2/repositories/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=['permissions_value'], - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.test_iam_permissions(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ['permissions_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_test_iam_permissions_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_test_iam_permissions") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_test_iam_permissions") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = iam_policy_pb2.TestIamPermissionsRequest() - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = json_format.MessageToJson(iam_policy_pb2.TestIamPermissionsResponse()) - req.return_value.content = return_value - - request = iam_policy_pb2.TestIamPermissionsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = iam_policy_pb2.TestIamPermissionsResponse() - - client.test_iam_permissions(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_project_settings_rest_bad_request(request_type=settings.GetProjectSettingsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/projectSettings'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.get_project_settings(request) - - -@pytest.mark.parametrize("request_type", [ - settings.GetProjectSettingsRequest, - dict, -]) -def test_get_project_settings_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/projectSettings'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_project_settings(request) - - # Establish that the response is the type that we expect. - 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.parametrize("null_interceptor", [True, False]) -def test_get_project_settings_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_get_project_settings") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_get_project_settings") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = settings.GetProjectSettingsRequest.pb(settings.GetProjectSettingsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) - req.return_value.content = return_value - - request = settings.GetProjectSettingsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = settings.ProjectSettings() - - client.get_project_settings(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_project_settings_rest_bad_request(request_type=settings.UpdateProjectSettingsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'project_settings': {'name': 'projects/sample1/projectSettings'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - client.update_project_settings(request) - - -@pytest.mark.parametrize("request_type", [ - settings.UpdateProjectSettingsRequest, - dict, -]) -def test_update_project_settings_rest_call_success(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'project_settings': {'name': 'projects/sample1/projectSettings'}} - request_init["project_settings"] = {'name': 'projects/sample1/projectSettings', 'legacy_redirection_state': 1} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = settings.UpdateProjectSettingsRequest.meta.fields["project_settings"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["project_settings"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["project_settings"][field])): - del request_init["project_settings"][field][i][subfield] - else: - del request_init["project_settings"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings( - name='name_value', - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_project_settings(request) - - # Establish that the response is the type that we expect. - 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.parametrize("null_interceptor", [True, False]) -def test_update_project_settings_rest_interceptors(null_interceptor): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.ArtifactRegistryRestInterceptor(), - ) - client = ArtifactRegistryClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "post_update_project_settings") as post, \ - mock.patch.object(transports.ArtifactRegistryRestInterceptor, "pre_update_project_settings") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = settings.UpdateProjectSettingsRequest.pb(settings.UpdateProjectSettingsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) - req.return_value.content = return_value - - request = settings.UpdateProjectSettingsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = settings.ProjectSettings() - - client.update_project_settings(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_location(request) - - -@pytest.mark.parametrize("request_type", [ - locations_pb2.GetLocationRequest, - dict, -]) -def test_get_location_rest(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.Location() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - - response = client.get_location(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.Location) - - -def test_list_locations_rest_bad_request(request_type=locations_pb2.ListLocationsRequest): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_locations(request) - - -@pytest.mark.parametrize("request_type", [ - locations_pb2.ListLocationsRequest, - dict, -]) -def test_list_locations_rest(request_type): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.ListLocationsResponse() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - - response = client.list_locations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) - -def test_initialize_client_w_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - assert client is not None - - -# 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_import_apt_artifacts_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.import_apt_artifacts), - '__call__') as call: - client.import_apt_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = apt_artifact.ImportAptArtifactsRequest() - - assert args[0] == request_msg - - -# 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_import_yum_artifacts_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.import_yum_artifacts), - '__call__') as call: - client.import_yum_artifacts(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = yum_artifact.ImportYumArtifactsRequest() - - assert args[0] == request_msg - - -# 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_repositories_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_repositories), - '__call__') as call: - client.list_repositories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.ListRepositoriesRequest() - - assert args[0] == request_msg - - -# 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_get_repository_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_repository), - '__call__') as call: - client.get_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.GetRepositoryRequest() - - assert args[0] == request_msg - - -# 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_create_repository_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_repository), - '__call__') as call: - client.create_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.CreateRepositoryRequest() - - assert args[0] == request_msg - - -# 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_update_repository_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_repository), - '__call__') as call: - client.update_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.UpdateRepositoryRequest() - - assert args[0] == request_msg - - -# 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_delete_repository_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_repository), - '__call__') as call: - client.delete_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.DeleteRepositoryRequest() - - assert args[0] == request_msg - - -# 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_packages_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_packages), - '__call__') as call: - client.list_packages(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.ListPackagesRequest() - - assert args[0] == request_msg - - -# 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_get_package_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_package), - '__call__') as call: - client.get_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.GetPackageRequest() - - assert args[0] == request_msg - - -# 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_delete_package_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_package), - '__call__') as call: - client.delete_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.DeletePackageRequest() - - assert args[0] == request_msg - - -# 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_versions_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_versions), - '__call__') as call: - client.list_versions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.ListVersionsRequest() - - assert args[0] == request_msg - - -# 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_get_version_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_version), - '__call__') as call: - client.get_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.GetVersionRequest() - - assert args[0] == request_msg - - -# 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_delete_version_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_version), - '__call__') as call: - client.delete_version(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.DeleteVersionRequest() - - assert args[0] == request_msg - - -# 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_files_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_files), - '__call__') as call: - client.list_files(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.ListFilesRequest() - - assert args[0] == request_msg - - -# 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_get_file_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_file), - '__call__') as call: - client.get_file(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.GetFileRequest() - - assert args[0] == request_msg - - -# 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_tags_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_tags), - '__call__') as call: - client.list_tags(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.ListTagsRequest() - - assert args[0] == request_msg - - -# 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_get_tag_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_tag), - '__call__') as call: - client.get_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.GetTagRequest() - - assert args[0] == request_msg - - -# 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_create_tag_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_tag), - '__call__') as call: - client.create_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.CreateTagRequest() - - assert args[0] == request_msg - - -# 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_update_tag_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_tag), - '__call__') as call: - client.update_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.UpdateTagRequest() - - assert args[0] == request_msg - - -# 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_delete_tag_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_tag), - '__call__') as call: - client.delete_tag(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.DeleteTagRequest() - - assert args[0] == request_msg - - -# 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_set_iam_policy_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy), - '__call__') as call: - client.set_iam_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() - - assert args[0] == request_msg - - -# 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_get_iam_policy_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy), - '__call__') as call: - client.get_iam_policy(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() - - assert args[0] == request_msg - - -# 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_test_iam_permissions_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), - '__call__') as call: - client.test_iam_permissions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() - - assert args[0] == request_msg - - -# 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_get_project_settings_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_project_settings), - '__call__') as call: - client.get_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.GetProjectSettingsRequest() - - assert args[0] == request_msg - - -# 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_update_project_settings_empty_call_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_project_settings), - '__call__') as call: - client.update_project_settings(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.UpdateProjectSettingsRequest() - - assert args[0] == request_msg - - -def test_artifact_registry_rest_lro_client(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - transport = client.transport - - # Ensure that we have an api-core operations client. - assert isinstance( - transport.operations_client, -operations_v1.AbstractOperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.ArtifactRegistryGrpcTransport, - ) - -def test_artifact_registry_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.ArtifactRegistryTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_artifact_registry_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.ArtifactRegistryTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.ArtifactRegistryTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'import_apt_artifacts', - 'import_yum_artifacts', - 'list_repositories', - 'get_repository', - 'create_repository', - 'update_repository', - 'delete_repository', - 'list_packages', - 'get_package', - 'delete_package', - 'list_versions', - 'get_version', - 'delete_version', - 'list_files', - 'get_file', - 'list_tags', - 'get_tag', - 'create_tag', - 'update_tag', - 'delete_tag', - 'set_iam_policy', - 'get_iam_policy', - 'test_iam_permissions', - 'get_project_settings', - 'update_project_settings', - 'get_location', - 'list_locations', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - # Catch all for all remaining methods and properties - remainder = [ - 'kind', - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_artifact_registry_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.ArtifactRegistryTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ArtifactRegistryTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', -), - quota_project_id="octopus", - ) - - -def test_artifact_registry_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.artifactregistry_v1beta2.services.artifact_registry.transports.ArtifactRegistryTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ArtifactRegistryTransport() - adc.assert_called_once() - - -def test_artifact_registry_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - ArtifactRegistryClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', -), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryGrpcAsyncIOTransport, - ], -) -def test_artifact_registry_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-platform.read-only',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryGrpcAsyncIOTransport, - transports.ArtifactRegistryRestTransport, - ], -) -def test_artifact_registry_transport_auth_gdch_credentials(transport_class): - host = 'https://language.com' - api_audience_tests = [None, 'https://language2.com'] - api_audience_expect = [host, 'https://language2.com'] - for t, e in zip(api_audience_tests, api_audience_expect): - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - gdch_mock = mock.MagicMock() - type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) - adc.return_value = (gdch_mock, None) - transport_class(host=host, api_audience=t) - gdch_mock.with_gdch_audience.assert_called_once_with( - e - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.ArtifactRegistryGrpcTransport, grpc_helpers), - (transports.ArtifactRegistryGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_artifact_registry_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "artifactregistry.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', -), - scopes=["1", "2"], - default_host="artifactregistry.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.ArtifactRegistryGrpcTransport, transports.ArtifactRegistryGrpcAsyncIOTransport]) -def test_artifact_registry_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key - ) - -def test_artifact_registry_http_transport_client_cert_source_for_mtls(): - cred = ga_credentials.AnonymousCredentials() - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: - transports.ArtifactRegistryRestTransport ( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) - - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_artifact_registry_host_no_port(transport_name): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='artifactregistry.googleapis.com'), - transport=transport_name, - ) - assert client.transport._host == ( - 'artifactregistry.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://artifactregistry.googleapis.com' - ) - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_artifact_registry_host_with_port(transport_name): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='artifactregistry.googleapis.com:8000'), - transport=transport_name, - ) - assert client.transport._host == ( - 'artifactregistry.googleapis.com:8000' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://artifactregistry.googleapis.com:8000' - ) - -@pytest.mark.parametrize("transport_name", [ - "rest", -]) -def test_artifact_registry_client_transport_session_collision(transport_name): - creds1 = ga_credentials.AnonymousCredentials() - creds2 = ga_credentials.AnonymousCredentials() - client1 = ArtifactRegistryClient( - credentials=creds1, - transport=transport_name, - ) - client2 = ArtifactRegistryClient( - credentials=creds2, - transport=transport_name, - ) - session1 = client1.transport.import_apt_artifacts._session - session2 = client2.transport.import_apt_artifacts._session - assert session1 != session2 - session1 = client1.transport.import_yum_artifacts._session - session2 = client2.transport.import_yum_artifacts._session - assert session1 != session2 - session1 = client1.transport.list_repositories._session - session2 = client2.transport.list_repositories._session - assert session1 != session2 - session1 = client1.transport.get_repository._session - session2 = client2.transport.get_repository._session - assert session1 != session2 - session1 = client1.transport.create_repository._session - session2 = client2.transport.create_repository._session - assert session1 != session2 - session1 = client1.transport.update_repository._session - session2 = client2.transport.update_repository._session - assert session1 != session2 - session1 = client1.transport.delete_repository._session - session2 = client2.transport.delete_repository._session - assert session1 != session2 - session1 = client1.transport.list_packages._session - session2 = client2.transport.list_packages._session - assert session1 != session2 - session1 = client1.transport.get_package._session - session2 = client2.transport.get_package._session - assert session1 != session2 - session1 = client1.transport.delete_package._session - session2 = client2.transport.delete_package._session - assert session1 != session2 - session1 = client1.transport.list_versions._session - session2 = client2.transport.list_versions._session - assert session1 != session2 - session1 = client1.transport.get_version._session - session2 = client2.transport.get_version._session - assert session1 != session2 - session1 = client1.transport.delete_version._session - session2 = client2.transport.delete_version._session - assert session1 != session2 - session1 = client1.transport.list_files._session - session2 = client2.transport.list_files._session - assert session1 != session2 - session1 = client1.transport.get_file._session - session2 = client2.transport.get_file._session - assert session1 != session2 - session1 = client1.transport.list_tags._session - session2 = client2.transport.list_tags._session - assert session1 != session2 - session1 = client1.transport.get_tag._session - session2 = client2.transport.get_tag._session - assert session1 != session2 - session1 = client1.transport.create_tag._session - session2 = client2.transport.create_tag._session - assert session1 != session2 - session1 = client1.transport.update_tag._session - session2 = client2.transport.update_tag._session - assert session1 != session2 - session1 = client1.transport.delete_tag._session - session2 = client2.transport.delete_tag._session - assert session1 != session2 - session1 = client1.transport.set_iam_policy._session - session2 = client2.transport.set_iam_policy._session - assert session1 != session2 - session1 = client1.transport.get_iam_policy._session - session2 = client2.transport.get_iam_policy._session - assert session1 != session2 - session1 = client1.transport.test_iam_permissions._session - session2 = client2.transport.test_iam_permissions._session - assert session1 != session2 - session1 = client1.transport.get_project_settings._session - session2 = client2.transport.get_project_settings._session - assert session1 != session2 - session1 = client1.transport.update_project_settings._session - session2 = client2.transport.update_project_settings._session - assert session1 != session2 -def test_artifact_registry_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ArtifactRegistryGrpcTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_artifact_registry_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.ArtifactRegistryGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.ArtifactRegistryGrpcTransport, transports.ArtifactRegistryGrpcAsyncIOTransport]) -def test_artifact_registry_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.ArtifactRegistryGrpcTransport, transports.ArtifactRegistryGrpcAsyncIOTransport]) -def test_artifact_registry_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_artifact_registry_grpc_lro_client(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_artifact_registry_grpc_lro_async_client(): - client = ArtifactRegistryAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_apt_artifact_path(): - project = "squid" - location = "clam" - repository = "whelk" - apt_artifact = "octopus" - expected = "projects/{project}/locations/{location}/repositories/{repository}/aptArtifacts/{apt_artifact}".format(project=project, location=location, repository=repository, apt_artifact=apt_artifact, ) - actual = ArtifactRegistryClient.apt_artifact_path(project, location, repository, apt_artifact) - assert expected == actual - - -def test_parse_apt_artifact_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - "repository": "cuttlefish", - "apt_artifact": "mussel", - } - path = ArtifactRegistryClient.apt_artifact_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_apt_artifact_path(path) - assert expected == actual - -def test_file_path(): - project = "winkle" - location = "nautilus" - repository = "scallop" - file = "abalone" - expected = "projects/{project}/locations/{location}/repositories/{repository}/files/{file}".format(project=project, location=location, repository=repository, file=file, ) - actual = ArtifactRegistryClient.file_path(project, location, repository, file) - assert expected == actual - - -def test_parse_file_path(): - expected = { - "project": "squid", - "location": "clam", - "repository": "whelk", - "file": "octopus", - } - path = ArtifactRegistryClient.file_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_file_path(path) - assert expected == actual - -def test_project_settings_path(): - project = "oyster" - expected = "projects/{project}/projectSettings".format(project=project, ) - actual = ArtifactRegistryClient.project_settings_path(project) - assert expected == actual - - -def test_parse_project_settings_path(): - expected = { - "project": "nudibranch", - } - path = ArtifactRegistryClient.project_settings_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_project_settings_path(path) - assert expected == actual - -def test_repository_path(): - project = "cuttlefish" - location = "mussel" - repository = "winkle" - expected = "projects/{project}/locations/{location}/repositories/{repository}".format(project=project, location=location, repository=repository, ) - actual = ArtifactRegistryClient.repository_path(project, location, repository) - assert expected == actual - - -def test_parse_repository_path(): - expected = { - "project": "nautilus", - "location": "scallop", - "repository": "abalone", - } - path = ArtifactRegistryClient.repository_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_repository_path(path) - assert expected == actual - -def test_tag_path(): - project = "squid" - location = "clam" - repository = "whelk" - package = "octopus" - tag = "oyster" - expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag}".format(project=project, location=location, repository=repository, package=package, tag=tag, ) - actual = ArtifactRegistryClient.tag_path(project, location, repository, package, tag) - assert expected == actual - - -def test_parse_tag_path(): - expected = { - "project": "nudibranch", - "location": "cuttlefish", - "repository": "mussel", - "package": "winkle", - "tag": "nautilus", - } - path = ArtifactRegistryClient.tag_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_tag_path(path) - assert expected == actual - -def test_version_path(): - project = "scallop" - location = "abalone" - repository = "squid" - package = "clam" - version = "whelk" - expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/versions/{version}".format(project=project, location=location, repository=repository, package=package, version=version, ) - actual = ArtifactRegistryClient.version_path(project, location, repository, package, version) - assert expected == actual - - -def test_parse_version_path(): - expected = { - "project": "octopus", - "location": "oyster", - "repository": "nudibranch", - "package": "cuttlefish", - "version": "mussel", - } - path = ArtifactRegistryClient.version_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_version_path(path) - assert expected == actual - -def test_yum_artifact_path(): - project = "winkle" - location = "nautilus" - repository = "scallop" - yum_artifact = "abalone" - expected = "projects/{project}/locations/{location}/repositories/{repository}/yumArtifacts/{yum_artifact}".format(project=project, location=location, repository=repository, yum_artifact=yum_artifact, ) - actual = ArtifactRegistryClient.yum_artifact_path(project, location, repository, yum_artifact) - assert expected == actual - - -def test_parse_yum_artifact_path(): - expected = { - "project": "squid", - "location": "clam", - "repository": "whelk", - "yum_artifact": "octopus", - } - path = ArtifactRegistryClient.yum_artifact_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_yum_artifact_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = ArtifactRegistryClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "nudibranch", - } - path = ArtifactRegistryClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder, ) - actual = ArtifactRegistryClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "mussel", - } - path = ArtifactRegistryClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "winkle" - expected = "organizations/{organization}".format(organization=organization, ) - actual = ArtifactRegistryClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nautilus", - } - path = ArtifactRegistryClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "scallop" - expected = "projects/{project}".format(project=project, ) - actual = ArtifactRegistryClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "abalone", - } - path = ArtifactRegistryClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "squid" - location = "clam" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = ArtifactRegistryClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "whelk", - "location": "octopus", - } - path = ArtifactRegistryClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = ArtifactRegistryClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_with_default_client_info(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.ArtifactRegistryTransport, '_prep_wrapped_messages') as prep: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.ArtifactRegistryTransport, '_prep_wrapped_messages') as prep: - transport_class = ArtifactRegistryClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - -def test_list_locations(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 = locations_pb2.ListLocationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.ListLocationsResponse() - response = client.list_locations(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, locations_pb2.ListLocationsResponse) -@pytest.mark.asyncio -async def test_list_locations_async(transport: str = "grpc_asyncio"): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), 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 = locations_pb2.ListLocationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - response = await client.list_locations(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, locations_pb2.ListLocationsResponse) - -def test_list_locations_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 = locations_pb2.ListLocationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - call.return_value = locations_pb2.ListLocationsResponse() - - client.list_locations(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_list_locations_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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 = locations_pb2.ListLocationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - await client.list_locations(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_list_locations_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.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.ListLocationsResponse() - - response = client.list_locations( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_list_locations_from_dict_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - response = await client.list_locations( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_get_location(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 = locations_pb2.GetLocationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.Location() - response = client.get_location(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, locations_pb2.Location) -@pytest.mark.asyncio -async def test_get_location_async(transport: str = "grpc_asyncio"): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), 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 = locations_pb2.GetLocationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - response = await client.get_location(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, locations_pb2.Location) - -def test_get_location_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 = locations_pb2.GetLocationRequest() - request.name = "locations/abc" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - call.return_value = locations_pb2.Location() - - client.get_location(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/abc",) in kw["metadata"] -@pytest.mark.asyncio -async def test_get_location_field_headers_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials() - ) - - # 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 = locations_pb2.GetLocationRequest() - request.name = "locations/abc" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - await client.get_location(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/abc",) in kw["metadata"] - -def test_get_location_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.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.Location() - - response = client.get_location( - request={ - "name": "locations/abc", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_get_location_from_dict_async(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - response = await client.get_location( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_transport_close_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc" - ) - with mock.patch.object(type(getattr(client.transport, "_grpc_channel")), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -@pytest.mark.asyncio -async def test_transport_close_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio" - ) - with mock.patch.object(type(getattr(client.transport, "_grpc_channel")), "close") as close: - async with client: - close.assert_not_called() - close.assert_called_once() - - -def test_transport_close_rest(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - with mock.patch.object(type(getattr(client.transport, "_session")), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -def test_client_ctx(): - transports = [ - 'rest', - 'grpc', - ] - for transport in transports: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() - -@pytest.mark.parametrize("client_class,transport_class", [ - (ArtifactRegistryClient, transports.ArtifactRegistryGrpcTransport), - (ArtifactRegistryAsyncClient, transports.ArtifactRegistryGrpcAsyncIOTransport), -]) -def test_api_key_credentials(client_class, transport_class): - with mock.patch.object( - google.auth._default, "get_api_key_credentials", create=True - ) as get_api_key_credentials: - mock_cred = mock.Mock() - get_api_key_credentials.return_value = mock_cred - options = client_options.ClientOptions() - options.api_key = "api_key" - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=mock_cred, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/__init__.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/__init__.py index 9a67e293611e..7baef65b58aa 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/__init__.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/__init__.py @@ -50,19 +50,31 @@ NpmPackage, PythonPackage, ) +from google.cloud.artifactregistry_v1.types.attachment import ( + Attachment, + CreateAttachmentRequest, + DeleteAttachmentRequest, + GetAttachmentRequest, + ListAttachmentsRequest, + ListAttachmentsResponse, +) from google.cloud.artifactregistry_v1.types.file import ( + DeleteFileRequest, File, GetFileRequest, Hash, ListFilesRequest, ListFilesResponse, + UpdateFileRequest, ) +from google.cloud.artifactregistry_v1.types.generic import GenericArtifact from google.cloud.artifactregistry_v1.types.package import ( DeletePackageRequest, GetPackageRequest, ListPackagesRequest, ListPackagesResponse, Package, + UpdatePackageRequest, ) from google.cloud.artifactregistry_v1.types.repository import ( CleanupPolicy, @@ -79,6 +91,15 @@ UpstreamPolicy, VirtualRepositoryConfig, ) +from google.cloud.artifactregistry_v1.types.rule import ( + CreateRuleRequest, + DeleteRuleRequest, + GetRuleRequest, + ListRulesRequest, + ListRulesResponse, + Rule, + UpdateRuleRequest, +) from google.cloud.artifactregistry_v1.types.service import OperationMetadata from google.cloud.artifactregistry_v1.types.settings import ( GetProjectSettingsRequest, @@ -101,6 +122,7 @@ GetVersionRequest, ListVersionsRequest, ListVersionsResponse, + UpdateVersionRequest, Version, VersionView, ) @@ -143,16 +165,26 @@ "MavenArtifact", "NpmPackage", "PythonPackage", + "Attachment", + "CreateAttachmentRequest", + "DeleteAttachmentRequest", + "GetAttachmentRequest", + "ListAttachmentsRequest", + "ListAttachmentsResponse", + "DeleteFileRequest", "File", "GetFileRequest", "Hash", "ListFilesRequest", "ListFilesResponse", + "UpdateFileRequest", + "GenericArtifact", "DeletePackageRequest", "GetPackageRequest", "ListPackagesRequest", "ListPackagesResponse", "Package", + "UpdatePackageRequest", "CleanupPolicy", "CleanupPolicyCondition", "CleanupPolicyMostRecentVersions", @@ -166,6 +198,13 @@ "UpdateRepositoryRequest", "UpstreamPolicy", "VirtualRepositoryConfig", + "CreateRuleRequest", + "DeleteRuleRequest", + "GetRuleRequest", + "ListRulesRequest", + "ListRulesResponse", + "Rule", + "UpdateRuleRequest", "OperationMetadata", "GetProjectSettingsRequest", "ProjectSettings", @@ -183,6 +222,7 @@ "GetVersionRequest", "ListVersionsRequest", "ListVersionsResponse", + "UpdateVersionRequest", "Version", "VersionView", "GetVPCSCConfigRequest", diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py index 739fdfae141c..558c8aab67c5 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py +++ b/packages/google-cloud-artifact-registry/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.12.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/__init__.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/__init__.py index e82fc91fac52..68ea6508ff88 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/__init__.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/__init__.py @@ -48,13 +48,31 @@ NpmPackage, PythonPackage, ) -from .types.file import File, GetFileRequest, Hash, ListFilesRequest, ListFilesResponse +from .types.attachment import ( + Attachment, + CreateAttachmentRequest, + DeleteAttachmentRequest, + GetAttachmentRequest, + ListAttachmentsRequest, + ListAttachmentsResponse, +) +from .types.file import ( + DeleteFileRequest, + File, + GetFileRequest, + Hash, + ListFilesRequest, + ListFilesResponse, + UpdateFileRequest, +) +from .types.generic import GenericArtifact from .types.package import ( DeletePackageRequest, GetPackageRequest, ListPackagesRequest, ListPackagesResponse, Package, + UpdatePackageRequest, ) from .types.repository import ( CleanupPolicy, @@ -71,6 +89,15 @@ UpstreamPolicy, VirtualRepositoryConfig, ) +from .types.rule import ( + CreateRuleRequest, + DeleteRuleRequest, + GetRuleRequest, + ListRulesRequest, + ListRulesResponse, + Rule, + UpdateRuleRequest, +) from .types.service import OperationMetadata from .types.settings import ( GetProjectSettingsRequest, @@ -93,6 +120,7 @@ GetVersionRequest, ListVersionsRequest, ListVersionsResponse, + UpdateVersionRequest, Version, VersionView, ) @@ -114,19 +142,27 @@ "ArtifactRegistryAsyncClient", "AptArtifact", "ArtifactRegistryClient", + "Attachment", "BatchDeleteVersionsMetadata", "BatchDeleteVersionsRequest", "CleanupPolicy", "CleanupPolicyCondition", "CleanupPolicyMostRecentVersions", + "CreateAttachmentRequest", "CreateRepositoryRequest", + "CreateRuleRequest", "CreateTagRequest", + "DeleteAttachmentRequest", + "DeleteFileRequest", "DeletePackageRequest", "DeleteRepositoryRequest", + "DeleteRuleRequest", "DeleteTagRequest", "DeleteVersionRequest", "DockerImage", "File", + "GenericArtifact", + "GetAttachmentRequest", "GetDockerImageRequest", "GetFileRequest", "GetMavenArtifactRequest", @@ -135,6 +171,7 @@ "GetProjectSettingsRequest", "GetPythonPackageRequest", "GetRepositoryRequest", + "GetRuleRequest", "GetTagRequest", "GetVPCSCConfigRequest", "GetVersionRequest", @@ -149,6 +186,8 @@ "ImportYumArtifactsMetadata", "ImportYumArtifactsRequest", "ImportYumArtifactsResponse", + "ListAttachmentsRequest", + "ListAttachmentsResponse", "ListDockerImagesRequest", "ListDockerImagesResponse", "ListFilesRequest", @@ -163,6 +202,8 @@ "ListPythonPackagesResponse", "ListRepositoriesRequest", "ListRepositoriesResponse", + "ListRulesRequest", + "ListRulesResponse", "ListTagsRequest", "ListTagsResponse", "ListVersionsRequest", @@ -175,11 +216,16 @@ "PythonPackage", "RemoteRepositoryConfig", "Repository", + "Rule", "Tag", + "UpdateFileRequest", + "UpdatePackageRequest", "UpdateProjectSettingsRequest", "UpdateRepositoryRequest", + "UpdateRuleRequest", "UpdateTagRequest", "UpdateVPCSCConfigRequest", + "UpdateVersionRequest", "UpstreamPolicy", "VPCSCConfig", "Version", diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_metadata.json b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_metadata.json index 2f151d61754f..7824e41e78fd 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_metadata.json +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_metadata.json @@ -15,16 +15,36 @@ "batch_delete_versions" ] }, + "CreateAttachment": { + "methods": [ + "create_attachment" + ] + }, "CreateRepository": { "methods": [ "create_repository" ] }, + "CreateRule": { + "methods": [ + "create_rule" + ] + }, "CreateTag": { "methods": [ "create_tag" ] }, + "DeleteAttachment": { + "methods": [ + "delete_attachment" + ] + }, + "DeleteFile": { + "methods": [ + "delete_file" + ] + }, "DeletePackage": { "methods": [ "delete_package" @@ -35,6 +55,11 @@ "delete_repository" ] }, + "DeleteRule": { + "methods": [ + "delete_rule" + ] + }, "DeleteTag": { "methods": [ "delete_tag" @@ -45,6 +70,11 @@ "delete_version" ] }, + "GetAttachment": { + "methods": [ + "get_attachment" + ] + }, "GetDockerImage": { "methods": [ "get_docker_image" @@ -90,6 +120,11 @@ "get_repository" ] }, + "GetRule": { + "methods": [ + "get_rule" + ] + }, "GetTag": { "methods": [ "get_tag" @@ -115,6 +150,11 @@ "import_yum_artifacts" ] }, + "ListAttachments": { + "methods": [ + "list_attachments" + ] + }, "ListDockerImages": { "methods": [ "list_docker_images" @@ -150,6 +190,11 @@ "list_repositories" ] }, + "ListRules": { + "methods": [ + "list_rules" + ] + }, "ListTags": { "methods": [ "list_tags" @@ -170,6 +215,16 @@ "test_iam_permissions" ] }, + "UpdateFile": { + "methods": [ + "update_file" + ] + }, + "UpdatePackage": { + "methods": [ + "update_package" + ] + }, "UpdateProjectSettings": { "methods": [ "update_project_settings" @@ -180,6 +235,11 @@ "update_repository" ] }, + "UpdateRule": { + "methods": [ + "update_rule" + ] + }, "UpdateTag": { "methods": [ "update_tag" @@ -189,6 +249,11 @@ "methods": [ "update_vpcsc_config" ] + }, + "UpdateVersion": { + "methods": [ + "update_version" + ] } } }, @@ -200,16 +265,36 @@ "batch_delete_versions" ] }, + "CreateAttachment": { + "methods": [ + "create_attachment" + ] + }, "CreateRepository": { "methods": [ "create_repository" ] }, + "CreateRule": { + "methods": [ + "create_rule" + ] + }, "CreateTag": { "methods": [ "create_tag" ] }, + "DeleteAttachment": { + "methods": [ + "delete_attachment" + ] + }, + "DeleteFile": { + "methods": [ + "delete_file" + ] + }, "DeletePackage": { "methods": [ "delete_package" @@ -220,6 +305,11 @@ "delete_repository" ] }, + "DeleteRule": { + "methods": [ + "delete_rule" + ] + }, "DeleteTag": { "methods": [ "delete_tag" @@ -230,6 +320,11 @@ "delete_version" ] }, + "GetAttachment": { + "methods": [ + "get_attachment" + ] + }, "GetDockerImage": { "methods": [ "get_docker_image" @@ -275,6 +370,11 @@ "get_repository" ] }, + "GetRule": { + "methods": [ + "get_rule" + ] + }, "GetTag": { "methods": [ "get_tag" @@ -300,6 +400,11 @@ "import_yum_artifacts" ] }, + "ListAttachments": { + "methods": [ + "list_attachments" + ] + }, "ListDockerImages": { "methods": [ "list_docker_images" @@ -335,6 +440,11 @@ "list_repositories" ] }, + "ListRules": { + "methods": [ + "list_rules" + ] + }, "ListTags": { "methods": [ "list_tags" @@ -355,6 +465,16 @@ "test_iam_permissions" ] }, + "UpdateFile": { + "methods": [ + "update_file" + ] + }, + "UpdatePackage": { + "methods": [ + "update_package" + ] + }, "UpdateProjectSettings": { "methods": [ "update_project_settings" @@ -365,6 +485,11 @@ "update_repository" ] }, + "UpdateRule": { + "methods": [ + "update_rule" + ] + }, "UpdateTag": { "methods": [ "update_tag" @@ -374,6 +499,11 @@ "methods": [ "update_vpcsc_config" ] + }, + "UpdateVersion": { + "methods": [ + "update_version" + ] } } }, @@ -385,16 +515,36 @@ "batch_delete_versions" ] }, + "CreateAttachment": { + "methods": [ + "create_attachment" + ] + }, "CreateRepository": { "methods": [ "create_repository" ] }, + "CreateRule": { + "methods": [ + "create_rule" + ] + }, "CreateTag": { "methods": [ "create_tag" ] }, + "DeleteAttachment": { + "methods": [ + "delete_attachment" + ] + }, + "DeleteFile": { + "methods": [ + "delete_file" + ] + }, "DeletePackage": { "methods": [ "delete_package" @@ -405,6 +555,11 @@ "delete_repository" ] }, + "DeleteRule": { + "methods": [ + "delete_rule" + ] + }, "DeleteTag": { "methods": [ "delete_tag" @@ -415,6 +570,11 @@ "delete_version" ] }, + "GetAttachment": { + "methods": [ + "get_attachment" + ] + }, "GetDockerImage": { "methods": [ "get_docker_image" @@ -460,6 +620,11 @@ "get_repository" ] }, + "GetRule": { + "methods": [ + "get_rule" + ] + }, "GetTag": { "methods": [ "get_tag" @@ -485,6 +650,11 @@ "import_yum_artifacts" ] }, + "ListAttachments": { + "methods": [ + "list_attachments" + ] + }, "ListDockerImages": { "methods": [ "list_docker_images" @@ -520,6 +690,11 @@ "list_repositories" ] }, + "ListRules": { + "methods": [ + "list_rules" + ] + }, "ListTags": { "methods": [ "list_tags" @@ -540,6 +715,16 @@ "test_iam_permissions" ] }, + "UpdateFile": { + "methods": [ + "update_file" + ] + }, + "UpdatePackage": { + "methods": [ + "update_package" + ] + }, "UpdateProjectSettings": { "methods": [ "update_project_settings" @@ -550,6 +735,11 @@ "update_repository" ] }, + "UpdateRule": { + "methods": [ + "update_rule" + ] + }, "UpdateTag": { "methods": [ "update_tag" @@ -559,6 +749,11 @@ "methods": [ "update_vpcsc_config" ] + }, + "UpdateVersion": { + "methods": [ + "update_version" + ] } } } diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py index 739fdfae141c..558c8aab67c5 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py +++ b/packages/google-cloud-artifact-registry/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.12.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py index d94e4e91b50d..08f7cb81309b 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py @@ -52,16 +52,26 @@ from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore 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 apt_artifact, artifact +from google.cloud.artifactregistry_v1.types import attachment +from google.cloud.artifactregistry_v1.types import attachment as gda_attachment +from google.cloud.artifactregistry_v1.types import file +from google.cloud.artifactregistry_v1.types import file as gda_file +from google.cloud.artifactregistry_v1.types import package +from google.cloud.artifactregistry_v1.types import package as gda_package 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 rule +from google.cloud.artifactregistry_v1.types import rule as gda_rule 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 +from google.cloud.artifactregistry_v1.types import version as gda_version from google.cloud.artifactregistry_v1.types import vpcsc_config from google.cloud.artifactregistry_v1.types import yum_artifact @@ -99,6 +109,8 @@ class ArtifactRegistryAsyncClient: parse_apt_artifact_path = staticmethod( ArtifactRegistryClient.parse_apt_artifact_path ) + attachment_path = staticmethod(ArtifactRegistryClient.attachment_path) + parse_attachment_path = staticmethod(ArtifactRegistryClient.parse_attachment_path) docker_image_path = staticmethod(ArtifactRegistryClient.docker_image_path) parse_docker_image_path = staticmethod( ArtifactRegistryClient.parse_docker_image_path @@ -123,6 +135,8 @@ class ArtifactRegistryAsyncClient: ) repository_path = staticmethod(ArtifactRegistryClient.repository_path) parse_repository_path = staticmethod(ArtifactRegistryClient.parse_repository_path) + rule_path = staticmethod(ArtifactRegistryClient.rule_path) + parse_rule_path = staticmethod(ArtifactRegistryClient.parse_rule_path) secret_version_path = staticmethod(ArtifactRegistryClient.secret_version_path) parse_secret_version_path = staticmethod( ArtifactRegistryClient.parse_secret_version_path @@ -2906,6 +2920,126 @@ async def sample_batch_delete_versions(): # Done; return the response. return response + async def update_version( + self, + request: Optional[Union[gda_version.UpdateVersionRequest, dict]] = None, + *, + version: Optional[gda_version.Version] = 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_version.Version: + r"""Updates a version. + + .. 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_version(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateVersionRequest( + ) + + # Make the request + response = await client.update_version(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateVersionRequest, dict]]): + The request object. The request to update a version. + version (:class:`google.cloud.artifactregistry_v1.types.Version`): + Required. The Version that replaces + the resource on the server. + + This corresponds to the ``version`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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_async.AsyncRetry): 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.Version: + The body of a version resource. A + version resource represents a collection + of components, such as files and other + data. This may correspond to a version + in many package management schemes. + + """ + # 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([version, 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, gda_version.UpdateVersionRequest): + request = gda_version.UpdateVersionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if version is not None: + request.version = version + 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._client._transport._wrapped_methods[ + self._client._transport.update_version + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("version.name", request.version.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def list_files( self, request: Optional[Union[file.ListFilesRequest, dict]] = None, @@ -3131,16 +3265,18 @@ async def sample_get_file(): # Done; return the response. return response - async def list_tags( + async def delete_file( self, - request: Optional[Union[tag.ListTagsRequest, dict]] = None, + request: Optional[Union[file.DeleteFileRequest, dict]] = None, *, - parent: Optional[str] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTagsAsyncPager: - r"""Lists tags. + ) -> operation_async.AsyncOperation: + r"""Deletes a file and all of its content. It is only + allowed on generic repositories. The returned operation + will complete once the file has been deleted. .. code-block:: python @@ -3153,30 +3289,33 @@ async def list_tags( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_list_tags(): + async def sample_delete_file(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.ListTagsRequest( + request = artifactregistry_v1.DeleteFileRequest( + name="name_value", ) # Make the request - page_result = client.list_tags(request=request) + operation = client.delete_file(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() # Handle the response - async for response in page_result: - print(response) + print(response) Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.ListTagsRequest, dict]]): - The request object. The request to list tags. - parent (:class:`str`): - The name of the parent package whose tags will be - listed. For example: - ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1``. + request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteFileRequest, dict]]): + The request object. The request to delete a file. + name (:class:`str`): + Required. The name of the file to + delete. - This corresponds to the ``parent`` field + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -3186,18 +3325,25 @@ async def sample_list_tags(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsAsyncPager: - The response from listing tags. + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. - Iterating over this object will yield - results and resolve additional pages - automatically. + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } """ # 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]) + 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 " @@ -3206,24 +3352,24 @@ async def sample_list_tags(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, tag.ListTagsRequest): - request = tag.ListTagsRequest(request) + if not isinstance(request, file.DeleteFileRequest): + request = file.DeleteFileRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: - request.parent = parent + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.list_tags + self._client._transport.delete_file ] # 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),)), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -3237,30 +3383,28 @@ async def sample_list_tags(): metadata=metadata, ) - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListTagsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, ) # Done; return the response. return response - async def get_tag( + async def update_file( self, - request: Optional[Union[tag.GetTagRequest, dict]] = None, + request: Optional[Union[gda_file.UpdateFileRequest, dict]] = None, *, - name: Optional[str] = None, + file: Optional[gda_file.File] = 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]] = (), - ) -> tag.Tag: - r"""Gets a tag. + ) -> gda_file.File: + r"""Updates a file. .. code-block:: python @@ -3273,26 +3417,36 @@ async def get_tag( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_get_tag(): + async def sample_update_file(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.GetTagRequest( + request = artifactregistry_v1.UpdateFileRequest( ) # Make the request - response = await client.get_tag(request=request) + response = await client.update_file(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetTagRequest, dict]]): - The request object. The request to retrieve a tag. - name (:class:`str`): - The name of the tag to retrieve. - This corresponds to the ``name`` field + request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateFileRequest, dict]]): + The request object. The request to update a file. + file (:class:`google.cloud.artifactregistry_v1.types.File`): + Required. The File that replaces the + resource on the server. + + This corresponds to the ``file`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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_async.AsyncRetry): Designation of what errors, if any, @@ -3302,16 +3456,16 @@ async def sample_get_tag(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. + google.cloud.artifactregistry_v1.types.File: + Files store content that is + potentially associated with Packages or + Versions. """ # 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]) + has_flattened_params = any([file, update_mask]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -3320,22 +3474,28 @@ async def sample_get_tag(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, tag.GetTagRequest): - request = tag.GetTagRequest(request) + if not isinstance(request, gda_file.UpdateFileRequest): + request = gda_file.UpdateFileRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if file is not None: + request.file = file + 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._client._transport._wrapped_methods[self._client._transport.get_tag] + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_file + ] # 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),)), + gapic_v1.routing_header.to_grpc_metadata( + (("file.name", request.file.name),) + ), ) # Validate the universe domain. @@ -3352,18 +3512,16 @@ async def sample_get_tag(): # Done; return the response. return response - async def create_tag( + async def list_tags( self, - request: Optional[Union[gda_tag.CreateTagRequest, dict]] = None, + request: Optional[Union[tag.ListTagsRequest, dict]] = None, *, parent: Optional[str] = None, - tag: Optional[gda_tag.Tag] = None, - tag_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> gda_tag.Tag: - r"""Creates a tag. + ) -> pagers.ListTagsAsyncPager: + r"""Lists tags. .. code-block:: python @@ -3376,42 +3534,32 @@ async def create_tag( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_create_tag(): + async def sample_list_tags(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.CreateTagRequest( + request = artifactregistry_v1.ListTagsRequest( ) # Make the request - response = await client.create_tag(request=request) + page_result = client.list_tags(request=request) # Handle the response - print(response) + async for response in page_result: + print(response) Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.CreateTagRequest, dict]]): - The request object. The request to create a new tag. + request (Optional[Union[google.cloud.artifactregistry_v1.types.ListTagsRequest, dict]]): + The request object. The request to list tags. parent (:class:`str`): - The name of the parent resource where - the tag will be created. + The name of the parent package whose tags will be + listed. For example: + ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - tag (:class:`google.cloud.artifactregistry_v1.types.Tag`): - The tag to be created. - This corresponds to the ``tag`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - tag_id (:class:`str`): - The tag id to use for this - repository. - - This corresponds to the ``tag_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3419,8 +3567,241 @@ async def sample_create_tag(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.Tag: - Tags point to a version and represent + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsAsyncPager: + The response from listing tags. + + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, tag.ListTagsRequest): + request = tag.ListTagsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_tags + ] + + # 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),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListTagsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_tag( + self, + request: Optional[Union[tag.GetTagRequest, 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]] = (), + ) -> tag.Tag: + r"""Gets a tag. + + .. 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_tag(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetTagRequest( + ) + + # Make the request + response = await client.get_tag(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetTagRequest, dict]]): + The request object. The request to retrieve a tag. + name (:class:`str`): + The name of the tag to retrieve. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.Tag: + Tags point to a version and represent + an alternative name that can be used to + access the version. + + """ + # 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, tag.GetTagRequest): + request = tag.GetTagRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.get_tag] + + # 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),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_tag( + self, + request: Optional[Union[gda_tag.CreateTagRequest, dict]] = None, + *, + parent: Optional[str] = None, + tag: Optional[gda_tag.Tag] = None, + tag_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gda_tag.Tag: + r"""Creates a tag. + + .. 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_create_tag(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.CreateTagRequest( + ) + + # Make the request + response = await client.create_tag(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.CreateTagRequest, dict]]): + The request object. The request to create a new tag. + parent (:class:`str`): + The name of the parent resource where + the tag will be created. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tag (:class:`google.cloud.artifactregistry_v1.types.Tag`): + The tag to be created. + This corresponds to the ``tag`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + tag_id (:class:`str`): + The tag id to use for this + repository. + + This corresponds to the ``tag_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.Tag: + Tags point to a version and represent an alternative name that can be used to access the version. @@ -3682,15 +4063,18 @@ async def sample_delete_tag(): metadata=metadata, ) - async def set_iam_policy( + async def create_rule( self, - request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, + request: Optional[Union[gda_rule.CreateRuleRequest, dict]] = None, *, + parent: Optional[str] = None, + rule: Optional[gda_rule.Rule] = None, + rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Updates the IAM policy for a given resource. + ) -> gda_rule.Rule: + r"""Creates a rule. .. code-block:: python @@ -3702,84 +4086,1070 @@ async def set_iam_policy( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - async def sample_set_iam_policy(): + async def sample_create_rule(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", + request = artifactregistry_v1.CreateRuleRequest( + parent="parent_value", ) # Make the request - response = await client.set_iam_policy(request=request) + response = await client.create_rule(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]): - The request object. Request message for ``SetIamPolicy`` method. - retry (google.api_core.retry_async.AsyncRetry): 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. + request (Optional[Union[google.cloud.artifactregistry_v1.types.CreateRuleRequest, dict]]): + The request object. The request to create a new rule. + parent (:class:`str`): + Required. The name of the parent + resource where the rule will be created. - Returns: + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + rule (:class:`google.cloud.artifactregistry_v1.types.Rule`): + The rule to be created. + This corresponds to the ``rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + rule_id (:class:`str`): + The rule id to use for this + repository. + + This corresponds to the ``rule_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. + + """ + # 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, rule, rule_id]) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, gda_rule.CreateRuleRequest): + request = gda_rule.CreateRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if rule is not None: + request.rule = rule + if rule_id is not None: + request.rule_id = rule_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_rule + ] + + # 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),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_rules( + self, + request: Optional[Union[rule.ListRulesRequest, 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.ListRulesAsyncPager: + r"""Lists rules. + + .. 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_rules(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_rules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.ListRulesRequest, dict]]): + The request object. The request to list rules. + parent (:class:`str`): + Required. The name of the parent repository whose rules + will be listed. For example: + ``projects/p1/locations/us-central1/repositories/repo1``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.ListRulesAsyncPager: + The response from listing rules. + + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, rule.ListRulesRequest): + request = rule.ListRulesRequest(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._client._transport._wrapped_methods[ + self._client._transport.list_rules + ] + + # 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),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListRulesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_rule( + self, + request: Optional[Union[rule.GetRuleRequest, 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]] = (), + ) -> rule.Rule: + r"""Gets a rule. + + .. 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_rule(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetRuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetRuleRequest, dict]]): + The request object. The request to retrieve a rule. + name (:class:`str`): + Required. The name of the rule to + retrieve. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. + + """ + # 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, rule.GetRuleRequest): + request = rule.GetRuleRequest(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._client._transport._wrapped_methods[self._client._transport.get_rule] + + # 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),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_rule( + self, + request: Optional[Union[gda_rule.UpdateRuleRequest, dict]] = None, + *, + rule: Optional[gda_rule.Rule] = 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_rule.Rule: + r"""Updates a rule. + + .. 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_rule(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateRuleRequest( + ) + + # Make the request + response = await client.update_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateRuleRequest, dict]]): + The request object. The request to update a rule. + rule (:class:`google.cloud.artifactregistry_v1.types.Rule`): + The rule that replaces the resource + on the server. + + This corresponds to the ``rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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_async.AsyncRetry): 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.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. + + """ + # 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([rule, 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, gda_rule.UpdateRuleRequest): + request = gda_rule.UpdateRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if rule is not None: + request.rule = rule + 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._client._transport._wrapped_methods[ + self._client._transport.update_rule + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("rule.name", request.rule.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_rule( + self, + request: Optional[Union[rule.DeleteRuleRequest, 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]] = (), + ) -> None: + r"""Deletes a rule. + + .. 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_delete_rule(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.DeleteRuleRequest( + name="name_value", + ) + + # Make the request + await client.delete_rule(request=request) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteRuleRequest, dict]]): + The request object. The request to delete a rule. + name (:class:`str`): + Required. The name of the rule to + delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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. + """ + # 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, rule.DeleteRuleRequest): + request = rule.DeleteRuleRequest(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._client._transport._wrapped_methods[ + self._client._transport.delete_rule + ] + + # 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),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + async def set_iam_policy( + self, + request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> policy_pb2.Policy: + r"""Updates the IAM policy for a given resource. + + .. 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 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + async def sample_set_iam_policy(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]): + The request object. Request message for ``SetIamPolicy`` method. + retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.policy_pb2.Policy: + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. + + A Policy is a collection of bindings. A binding binds + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** + + :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + + **YAML example:** + + :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + + For a description of IAM and its features, see the + [IAM + documentation](\ https://cloud.google.com/iam/docs/). + + """ + # Create or coerce a protobuf request object. + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = iam_policy_pb2.SetIamPolicyRequest(**request) + elif not request: + request = iam_policy_pb2.SetIamPolicyRequest() + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.set_iam_policy + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_iam_policy( + self, + request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> policy_pb2.Policy: + r"""Gets the IAM policy for a given resource. + + .. 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 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + async def sample_get_iam_policy(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]): + The request object. Request message for ``GetIamPolicy`` method. + retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.policy_pb2.Policy: An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. + A Policy is a collection of bindings. A binding binds + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** + + :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + + **YAML example:** + + :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + + For a description of IAM and its features, see the + [IAM + documentation](\ https://cloud.google.com/iam/docs/). + + """ + # Create or coerce a protobuf request object. + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = iam_policy_pb2.GetIamPolicyRequest(**request) + elif not request: + request = iam_policy_pb2.GetIamPolicyRequest() + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_iam_policy + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def test_iam_permissions( + self, + request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> iam_policy_pb2.TestIamPermissionsResponse: + r"""Tests if the caller has a list of permissions on a + resource. + + .. code-block:: python - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + # 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 + from google.iam.v1 import iam_policy_pb2 # type: ignore - **JSON example:** + async def sample_test_iam_permissions(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) - **YAML example:** + # Make the request + response = await client.test_iam_permissions(request=request) - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + # Handle the response + print(response) - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). + Args: + request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]): + The request object. Request message for ``TestIamPermissions`` method. + retry (google.api_core.retry_async.AsyncRetry): 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.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: + Response message for TestIamPermissions method. + """ + # Create or coerce a protobuf request object. + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = iam_policy_pb2.TestIamPermissionsRequest(**request) + elif not request: + request = iam_policy_pb2.TestIamPermissionsRequest() + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.test_iam_permissions + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_project_settings( + self, + request: Optional[Union[settings.GetProjectSettingsRequest, 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]] = (), + ) -> settings.ProjectSettings: + r"""Retrieves the Settings 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_project_settings(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetProjectSettingsRequest( + name="name_value", + ) + + # Make the request + response = await client.get_project_settings(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest, dict]]): + The request object. Gets the redirection status for a + project. + name (:class:`str`): + Required. The name of the + projectSettings 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_async.AsyncRetry): 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.ProjectSettings: + The Artifact Registry settings 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, settings.GetProjectSettingsRequest): + request = settings.GetProjectSettingsRequest(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._client._transport._wrapped_methods[ + self._client._transport.get_project_settings + ] + + # 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),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_project_settings( + self, + request: Optional[Union[settings.UpdateProjectSettingsRequest, dict]] = None, + *, + project_settings: Optional[settings.ProjectSettings] = 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]] = (), + ) -> settings.ProjectSettings: + r"""Updates the Settings 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_project_settings(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryAsyncClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateProjectSettingsRequest( + ) + + # Make the request + response = await client.update_project_settings(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest, dict]]): + The request object. Sets the settings of the project. + project_settings (:class:`google.cloud.artifactregistry_v1.types.ProjectSettings`): + The project settings. + This corresponds to the ``project_settings`` 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_async.AsyncRetry): 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.ProjectSettings: + The Artifact Registry settings that + apply to a Project. """ # Create or coerce a protobuf request object. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.SetIamPolicyRequest(**request) - elif not request: - request = iam_policy_pb2.SetIamPolicyRequest() + # - 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([project_settings, 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, settings.UpdateProjectSettingsRequest): + request = settings.UpdateProjectSettingsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project_settings is not None: + request.project_settings = project_settings + 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._client._transport._wrapped_methods[ - self._client._transport.set_iam_policy + self._client._transport.update_project_settings ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata( + (("project_settings.name", request.project_settings.name),) + ), ) # Validate the universe domain. @@ -3796,15 +5166,16 @@ async def sample_set_iam_policy(): # Done; return the response. return response - async def get_iam_policy( + async def get_vpcsc_config( self, - request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, + 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]] = (), - ) -> policy_pb2.Policy: - r"""Gets the IAM policy for a given resource. + ) -> vpcsc_config.VPCSCConfig: + r"""Retrieves the VPCSC Config for the Project. .. code-block:: python @@ -3816,26 +5187,32 @@ async def get_iam_policy( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - async def sample_get_iam_policy(): + async def sample_get_vpcsc_config(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", + request = artifactregistry_v1.GetVPCSCConfigRequest( + name="name_value", ) # Make the request - response = await client.get_iam_policy(request=request) + response = await client.get_vpcsc_config(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]): - The request object. Request message for ``GetIamPolicy`` method. + 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_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3843,57 +5220,157 @@ async def sample_get_iam_policy(): sent along with the request as metadata. Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. + google.cloud.artifactregistry_v1.types.VPCSCConfig: + The Artifact Registry VPC SC config + that apply to a Project. - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. + """ + # 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." + ) - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, vpcsc_config.GetVPCSCConfigRequest): + request = vpcsc_config.GetVPCSCConfigRequest(request) - **JSON example:** + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_vpcsc_config + ] - **YAML example:** + # 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),)), + ) - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + # Validate the universe domain. + self._client._validate_universe_domain() - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). + # 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_async.AsyncRetry): 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. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.GetIamPolicyRequest(**request) - elif not request: - request = iam_policy_pb2.GetIamPolicyRequest() + # - 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + 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._client._transport._wrapped_methods[ - self._client._transport.get_iam_policy + self._client._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((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata( + (("vpcsc_config.name", request.vpcsc_config.name),) + ), ) # Validate the universe domain. @@ -3910,16 +5387,17 @@ async def sample_get_iam_policy(): # Done; return the response. return response - async def test_iam_permissions( + async def update_package( self, - request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, + request: Optional[Union[gda_package.UpdatePackageRequest, dict]] = None, *, + package: Optional[gda_package.Package] = 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]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Tests if the caller has a list of permissions on a - resource. + ) -> gda_package.Package: + r"""Updates a package. .. code-block:: python @@ -3931,27 +5409,39 @@ async def test_iam_permissions( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - async def sample_test_iam_permissions(): + async def sample_update_package(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], + request = artifactregistry_v1.UpdatePackageRequest( ) # Make the request - response = await client.test_iam_permissions(request=request) + response = await client.update_package(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]): - The request object. Request message for ``TestIamPermissions`` method. + request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdatePackageRequest, dict]]): + The request object. The request to update a package. + package (:class:`google.cloud.artifactregistry_v1.types.Package`): + The package that replaces the + resource on the server. + + This corresponds to the ``package`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3959,27 +5449,45 @@ async def sample_test_iam_permissions(): sent along with the request as metadata. Returns: - google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: - Response message for TestIamPermissions method. + google.cloud.artifactregistry_v1.types.Package: + Packages are named collections of + versions. + """ # Create or coerce a protobuf request object. - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.TestIamPermissionsRequest(**request) - elif not request: - request = iam_policy_pb2.TestIamPermissionsRequest() + # - 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([package, 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, gda_package.UpdatePackageRequest): + request = gda_package.UpdatePackageRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if package is not None: + request.package = package + 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._client._transport._wrapped_methods[ - self._client._transport.test_iam_permissions + self._client._transport.update_package ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata( + (("package.name", request.package.name),) + ), ) # Validate the universe domain. @@ -3996,16 +5504,16 @@ async def sample_test_iam_permissions(): # Done; return the response. return response - async def get_project_settings( + async def list_attachments( self, - request: Optional[Union[settings.GetProjectSettingsRequest, dict]] = None, + request: Optional[Union[attachment.ListAttachmentsRequest, dict]] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> settings.ProjectSettings: - r"""Retrieves the Settings for the Project. + ) -> pagers.ListAttachmentsAsyncPager: + r"""Lists attachments. .. code-block:: python @@ -4018,30 +5526,31 @@ async def get_project_settings( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_get_project_settings(): + async def sample_list_attachments(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.GetProjectSettingsRequest( - name="name_value", + request = artifactregistry_v1.ListAttachmentsRequest( + parent="parent_value", ) # Make the request - response = await client.get_project_settings(request=request) + page_result = client.list_attachments(request=request) # Handle the response - print(response) + async for response in page_result: + print(response) Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest, dict]]): - The request object. Gets the redirection status for a - project. - name (:class:`str`): - Required. The name of the - projectSettings resource. + request (Optional[Union[google.cloud.artifactregistry_v1.types.ListAttachmentsRequest, dict]]): + The request object. The request to list attachments. + parent (:class:`str`): + Required. The name of the parent + resource whose attachments will be + listed. - This corresponds to the ``name`` field + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -4051,15 +5560,18 @@ async def sample_get_project_settings(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.ProjectSettings: - The Artifact Registry settings that - apply to a Project. + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListAttachmentsAsyncPager: + The response from listing + attachments. + 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([name]) + 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 " @@ -4068,24 +5580,24 @@ async def sample_get_project_settings(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, settings.GetProjectSettingsRequest): - request = settings.GetProjectSettingsRequest(request) + if not isinstance(request, attachment.ListAttachmentsRequest): + request = attachment.ListAttachmentsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.get_project_settings + self._client._transport.list_attachments ] # 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),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -4099,20 +5611,30 @@ async def sample_get_project_settings(): metadata=metadata, ) + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListAttachmentsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + # Done; return the response. return response - async def update_project_settings( + async def get_attachment( self, - request: Optional[Union[settings.UpdateProjectSettingsRequest, dict]] = None, + request: Optional[Union[attachment.GetAttachmentRequest, dict]] = None, *, - project_settings: Optional[settings.ProjectSettings] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> settings.ProjectSettings: - r"""Updates the Settings for the Project. + ) -> attachment.Attachment: + r"""Gets an attachment. .. code-block:: python @@ -4125,33 +5647,30 @@ async def update_project_settings( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_update_project_settings(): + async def sample_get_attachment(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.UpdateProjectSettingsRequest( + request = artifactregistry_v1.GetAttachmentRequest( + name="name_value", ) # Make the request - response = await client.update_project_settings(request=request) + response = await client.get_attachment(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest, dict]]): - The request object. Sets the settings of the project. - project_settings (:class:`google.cloud.artifactregistry_v1.types.ProjectSettings`): - The project settings. - This corresponds to the ``project_settings`` 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. + request (Optional[Union[google.cloud.artifactregistry_v1.types.GetAttachmentRequest, dict]]): + The request object. The request to retrieve an + attachment. + name (:class:`str`): + Required. The name of the attachment + to retrieve. - This corresponds to the ``update_mask`` field + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -4161,15 +5680,18 @@ async def sample_update_project_settings(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.ProjectSettings: - The Artifact Registry settings that - apply to a Project. + google.cloud.artifactregistry_v1.types.Attachment: + An Attachment refers to additional + metadata that can be attached to + artifacts in Artifact Registry. An + attachment consists of one or more + files. """ # 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([project_settings, update_mask]) + 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 " @@ -4178,28 +5700,24 @@ async def sample_update_project_settings(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, settings.UpdateProjectSettingsRequest): - request = settings.UpdateProjectSettingsRequest(request) + if not isinstance(request, attachment.GetAttachmentRequest): + request = attachment.GetAttachmentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_settings is not None: - request.project_settings = project_settings - if update_mask is not None: - request.update_mask = update_mask + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.update_project_settings + self._client._transport.get_attachment ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("project_settings.name", request.project_settings.name),) - ), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -4216,16 +5734,20 @@ async def sample_update_project_settings(): # Done; return the response. return response - async def get_vpcsc_config( + async def create_attachment( self, - request: Optional[Union[vpcsc_config.GetVPCSCConfigRequest, dict]] = None, + request: Optional[Union[gda_attachment.CreateAttachmentRequest, dict]] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, + attachment: Optional[gda_attachment.Attachment] = None, + attachment_id: 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. + ) -> operation_async.AsyncOperation: + r"""Creates an attachment. The returned Operation will + finish once the attachment has been created. Its + response will be the created attachment. .. code-block:: python @@ -4238,29 +5760,55 @@ async def get_vpcsc_config( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_get_vpcsc_config(): + async def sample_create_attachment(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.GetVPCSCConfigRequest( - name="name_value", + attachment = artifactregistry_v1.Attachment() + attachment.target = "target_value" + attachment.files = ['files_value1', 'files_value2'] + + request = artifactregistry_v1.CreateAttachmentRequest( + parent="parent_value", + attachment_id="attachment_id_value", + attachment=attachment, ) # Make the request - response = await client.get_vpcsc_config(request=request) + operation = client.create_attachment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() # 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. + request (Optional[Union[google.cloud.artifactregistry_v1.types.CreateAttachmentRequest, dict]]): + The request object. The request to create a new + attachment. + parent (:class:`str`): + Required. The name of the parent + resource where the attachment will be + created. - This corresponds to the ``name`` field + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + attachment (:class:`google.cloud.artifactregistry_v1.types.Attachment`): + Required. The attachment to be + created. + + This corresponds to the ``attachment`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + attachment_id (:class:`str`): + Required. The attachment id to use + for this attachment. + + This corresponds to the ``attachment_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -4270,15 +5818,18 @@ async def sample_get_vpcsc_config(): 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. + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.artifactregistry_v1.types.Attachment` An Attachment refers to additional metadata that can be attached to + artifacts in Artifact Registry. An attachment + consists of one or more files. """ # 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]) + has_flattened_params = any([parent, attachment, attachment_id]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -4287,24 +5838,28 @@ async def sample_get_vpcsc_config(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, vpcsc_config.GetVPCSCConfigRequest): - request = vpcsc_config.GetVPCSCConfigRequest(request) + if not isinstance(request, gda_attachment.CreateAttachmentRequest): + request = gda_attachment.CreateAttachmentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent + if attachment is not None: + request.attachment = attachment + if attachment_id is not None: + request.attachment_id = attachment_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.get_vpcsc_config + self._client._transport.create_attachment ] # 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),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -4318,22 +5873,29 @@ async def sample_get_vpcsc_config(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + gda_attachment.Attachment, + metadata_type=service.OperationMetadata, + ) + # Done; return the response. return response - async def update_vpcsc_config( + async def delete_attachment( self, - request: Optional[ - Union[gda_vpcsc_config.UpdateVPCSCConfigRequest, dict] - ] = None, + request: Optional[Union[attachment.DeleteAttachmentRequest, dict]] = None, *, - vpcsc_config: Optional[gda_vpcsc_config.VPCSCConfig] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, + name: Optional[str] = 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. + ) -> operation_async.AsyncOperation: + r"""Deletes an attachment. The returned Operation will finish once + the attachments has been deleted. It will not have any Operation + metadata and will return a ``google.protobuf.Empty`` response. .. code-block:: python @@ -4346,33 +5908,33 @@ async def update_vpcsc_config( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - async def sample_update_vpcsc_config(): + async def sample_delete_attachment(): # Create a client client = artifactregistry_v1.ArtifactRegistryAsyncClient() # Initialize request argument(s) - request = artifactregistry_v1.UpdateVPCSCConfigRequest( + request = artifactregistry_v1.DeleteAttachmentRequest( + name="name_value", ) # Make the request - response = await client.update_vpcsc_config(request=request) + operation = client.delete_attachment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() # 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. + request (Optional[Union[google.cloud.artifactregistry_v1.types.DeleteAttachmentRequest, dict]]): + The request object. The request to delete an attachment. + name (:class:`str`): + Required. The name of the attachment + to delete. - This corresponds to the ``update_mask`` field + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -4382,15 +5944,25 @@ async def sample_update_vpcsc_config(): 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. + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } """ # 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]) + 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 " @@ -4399,28 +5971,24 @@ async def sample_update_vpcsc_config(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, gda_vpcsc_config.UpdateVPCSCConfigRequest): - request = gda_vpcsc_config.UpdateVPCSCConfigRequest(request) + if not isinstance(request, attachment.DeleteAttachmentRequest): + request = attachment.DeleteAttachmentRequest(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 + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.update_vpcsc_config + self._client._transport.delete_attachment ] # 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),) - ), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -4434,6 +6002,14 @@ async def sample_update_vpcsc_config(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + # Done; return the response. return response diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/client.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/client.py index adde437957cc..a0d0cebe9588 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/client.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/client.py @@ -58,16 +58,26 @@ from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore 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 apt_artifact, artifact +from google.cloud.artifactregistry_v1.types import attachment +from google.cloud.artifactregistry_v1.types import attachment as gda_attachment +from google.cloud.artifactregistry_v1.types import file +from google.cloud.artifactregistry_v1.types import file as gda_file +from google.cloud.artifactregistry_v1.types import package +from google.cloud.artifactregistry_v1.types import package as gda_package 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 rule +from google.cloud.artifactregistry_v1.types import rule as gda_rule 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 +from google.cloud.artifactregistry_v1.types import version as gda_version from google.cloud.artifactregistry_v1.types import vpcsc_config from google.cloud.artifactregistry_v1.types import yum_artifact @@ -240,6 +250,30 @@ def parse_apt_artifact_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def attachment_path( + project: str, + location: str, + repository: str, + attachment: str, + ) -> str: + """Returns a fully-qualified attachment string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/attachments/{attachment}".format( + project=project, + location=location, + repository=repository, + attachment=attachment, + ) + + @staticmethod + def parse_attachment_path(path: str) -> Dict[str, str]: + """Parses a attachment path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/attachments/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def docker_image_path( project: str, @@ -423,6 +457,30 @@ def parse_repository_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def rule_path( + project: str, + location: str, + repository: str, + rule: str, + ) -> str: + """Returns a fully-qualified rule string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/rules/{rule}".format( + project=project, + location=location, + repository=repository, + rule=rule, + ) + + @staticmethod + def parse_rule_path(path: str) -> Dict[str, str]: + """Parses a rule path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/rules/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def secret_version_path( project: str, @@ -3526,6 +3584,123 @@ def sample_batch_delete_versions(): # Done; return the response. return response + def update_version( + self, + request: Optional[Union[gda_version.UpdateVersionRequest, dict]] = None, + *, + version: Optional[gda_version.Version] = 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_version.Version: + r"""Updates a version. + + .. 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_version(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateVersionRequest( + ) + + # Make the request + response = client.update_version(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.UpdateVersionRequest, dict]): + The request object. The request to update a version. + version (google.cloud.artifactregistry_v1.types.Version): + Required. The Version that replaces + the resource on the server. + + This corresponds to the ``version`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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.Version: + The body of a version resource. A + version resource represents a collection + of components, such as files and other + data. This may correspond to a version + in many package management schemes. + + """ + # 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([version, 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, gda_version.UpdateVersionRequest): + request = gda_version.UpdateVersionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if version is not None: + request.version = version + 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_version] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("version.name", request.version.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def list_files( self, request: Optional[Union[file.ListFilesRequest, dict]] = None, @@ -3747,16 +3922,18 @@ def sample_get_file(): # Done; return the response. return response - def list_tags( + def delete_file( self, - request: Optional[Union[tag.ListTagsRequest, dict]] = None, + request: Optional[Union[file.DeleteFileRequest, dict]] = None, *, - parent: Optional[str] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.ListTagsPager: - r"""Lists tags. + ) -> operation.Operation: + r"""Deletes a file and all of its content. It is only + allowed on generic repositories. The returned operation + will complete once the file has been deleted. .. code-block:: python @@ -3769,30 +3946,33 @@ def list_tags( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_list_tags(): + def sample_delete_file(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.ListTagsRequest( + request = artifactregistry_v1.DeleteFileRequest( + name="name_value", ) # Make the request - page_result = client.list_tags(request=request) + operation = client.delete_file(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() # Handle the response - for response in page_result: - print(response) + print(response) Args: - request (Union[google.cloud.artifactregistry_v1.types.ListTagsRequest, dict]): - The request object. The request to list tags. - parent (str): - The name of the parent package whose tags will be - listed. For example: - ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1``. + request (Union[google.cloud.artifactregistry_v1.types.DeleteFileRequest, dict]): + The request object. The request to delete a file. + name (str): + Required. The name of the file to + delete. - This corresponds to the ``parent`` field + 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, @@ -3802,18 +3982,25 @@ def sample_list_tags(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsPager: - The response from listing tags. + google.api_core.operation.Operation: + An object representing a long-running operation. - Iterating over this object will yield - results and resolve additional pages - automatically. + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } """ # 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]) + 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 " @@ -3822,21 +4009,21 @@ def sample_list_tags(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, tag.ListTagsRequest): - request = tag.ListTagsRequest(request) + if not isinstance(request, file.DeleteFileRequest): + request = file.DeleteFileRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: - request.parent = parent + 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.list_tags] + rpc = self._transport._wrapped_methods[self._transport.delete_file] # 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),)), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -3850,30 +4037,28 @@ def sample_list_tags(): metadata=metadata, ) - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListTagsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, ) # Done; return the response. return response - def get_tag( + def update_file( self, - request: Optional[Union[tag.GetTagRequest, dict]] = None, + request: Optional[Union[gda_file.UpdateFileRequest, dict]] = None, *, - name: Optional[str] = None, + file: Optional[gda_file.File] = 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]] = (), - ) -> tag.Tag: - r"""Gets a tag. + ) -> gda_file.File: + r"""Updates a file. .. code-block:: python @@ -3886,26 +4071,36 @@ def get_tag( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_get_tag(): + def sample_update_file(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.GetTagRequest( + request = artifactregistry_v1.UpdateFileRequest( ) # Make the request - response = client.get_tag(request=request) + response = client.update_file(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.artifactregistry_v1.types.GetTagRequest, dict]): - The request object. The request to retrieve a tag. - name (str): - The name of the tag to retrieve. - This corresponds to the ``name`` field + request (Union[google.cloud.artifactregistry_v1.types.UpdateFileRequest, dict]): + The request object. The request to update a file. + file (google.cloud.artifactregistry_v1.types.File): + Required. The File that replaces the + resource on the server. + + This corresponds to the ``file`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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, @@ -3915,16 +4110,16 @@ def sample_get_tag(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.Tag: - Tags point to a version and represent - an alternative name that can be used to - access the version. + google.cloud.artifactregistry_v1.types.File: + Files store content that is + potentially associated with Packages or + Versions. """ # 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]) + has_flattened_params = any([file, update_mask]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -3933,21 +4128,25 @@ def sample_get_tag(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, tag.GetTagRequest): - request = tag.GetTagRequest(request) + if not isinstance(request, gda_file.UpdateFileRequest): + request = gda_file.UpdateFileRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if file is not None: + request.file = file + 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.get_tag] + rpc = self._transport._wrapped_methods[self._transport.update_file] # 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),)), + gapic_v1.routing_header.to_grpc_metadata( + (("file.name", request.file.name),) + ), ) # Validate the universe domain. @@ -3964,18 +4163,16 @@ def sample_get_tag(): # Done; return the response. return response - def create_tag( + def list_tags( self, - request: Optional[Union[gda_tag.CreateTagRequest, dict]] = None, + request: Optional[Union[tag.ListTagsRequest, dict]] = None, *, parent: Optional[str] = None, - tag: Optional[gda_tag.Tag] = None, - tag_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> gda_tag.Tag: - r"""Creates a tag. + ) -> pagers.ListTagsPager: + r"""Lists tags. .. code-block:: python @@ -3988,16 +4185,235 @@ def create_tag( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_create_tag(): + def sample_list_tags(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.CreateTagRequest( + request = artifactregistry_v1.ListTagsRequest( ) # Make the request - response = client.create_tag(request=request) + page_result = client.list_tags(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.ListTagsRequest, dict]): + The request object. The request to list tags. + parent (str): + The name of the parent package whose tags will be + listed. For example: + ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1``. + + 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.ListTagsPager: + The response from listing tags. + + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, tag.ListTagsRequest): + request = tag.ListTagsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_tags] + + # 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),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListTagsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_tag( + self, + request: Optional[Union[tag.GetTagRequest, 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]] = (), + ) -> tag.Tag: + r"""Gets a tag. + + .. 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_tag(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetTagRequest( + ) + + # Make the request + response = client.get_tag(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.GetTagRequest, dict]): + The request object. The request to retrieve a tag. + name (str): + The name of the tag to retrieve. + 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.Tag: + Tags point to a version and represent + an alternative name that can be used to + access the version. + + """ + # 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, tag.GetTagRequest): + request = tag.GetTagRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_tag] + + # 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),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_tag( + self, + request: Optional[Union[gda_tag.CreateTagRequest, dict]] = None, + *, + parent: Optional[str] = None, + tag: Optional[gda_tag.Tag] = None, + tag_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gda_tag.Tag: + r"""Creates a tag. + + .. 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_create_tag(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.CreateTagRequest( + ) + + # Make the request + response = client.create_tag(request=request) # Handle the response print(response) @@ -4285,15 +4701,18 @@ def sample_delete_tag(): metadata=metadata, ) - def set_iam_policy( + def create_rule( self, - request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, + request: Optional[Union[gda_rule.CreateRuleRequest, dict]] = None, *, + parent: Optional[str] = None, + rule: Optional[gda_rule.Rule] = None, + rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> policy_pb2.Policy: - r"""Updates the IAM policy for a given resource. + ) -> gda_rule.Rule: + r"""Creates a rule. .. code-block:: python @@ -4305,26 +4724,44 @@ def set_iam_policy( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_set_iam_policy(): + def sample_create_rule(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", + request = artifactregistry_v1.CreateRuleRequest( + parent="parent_value", ) # Make the request - response = client.set_iam_policy(request=request) + response = client.create_rule(request=request) # Handle the response print(response) Args: - request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): - The request object. Request message for ``SetIamPolicy`` method. + request (Union[google.cloud.artifactregistry_v1.types.CreateRuleRequest, dict]): + The request object. The request to create a new rule. + parent (str): + Required. The name of the parent + resource where the rule will be created. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + rule (google.cloud.artifactregistry_v1.types.Rule): + The rule to be created. + This corresponds to the ``rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + rule_id (str): + The rule id to use for this + repository. + + This corresponds to the ``rule_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4332,18 +4769,666 @@ def sample_set_iam_policy(): sent along with the request as metadata. Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. + google.cloud.artifactregistry_v1.types.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding + """ + # 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, rule, rule_id]) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, gda_rule.CreateRuleRequest): + request = gda_rule.CreateRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if rule is not None: + request.rule = rule + if rule_id is not None: + request.rule_id = rule_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_rule] + + # 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),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_rules( + self, + request: Optional[Union[rule.ListRulesRequest, 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.ListRulesPager: + r"""Lists rules. + + .. 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_rules(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.ListRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_rules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.ListRulesRequest, dict]): + The request object. The request to list rules. + parent (str): + Required. The name of the parent repository whose rules + will be listed. For example: + ``projects/p1/locations/us-central1/repositories/repo1``. + + 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.ListRulesPager: + The response from listing rules. + + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, rule.ListRulesRequest): + request = rule.ListRulesRequest(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_rules] + + # 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),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListRulesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_rule( + self, + request: Optional[Union[rule.GetRuleRequest, 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]] = (), + ) -> rule.Rule: + r"""Gets a rule. + + .. 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_rule(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetRuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.GetRuleRequest, dict]): + The request object. The request to retrieve a rule. + name (str): + Required. The name of the rule to + retrieve. + + 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.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. + + """ + # 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, rule.GetRuleRequest): + request = rule.GetRuleRequest(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_rule] + + # 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),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_rule( + self, + request: Optional[Union[gda_rule.UpdateRuleRequest, dict]] = None, + *, + rule: Optional[gda_rule.Rule] = 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_rule.Rule: + r"""Updates a rule. + + .. 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_rule(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateRuleRequest( + ) + + # Make the request + response = client.update_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.UpdateRuleRequest, dict]): + The request object. The request to update a rule. + rule (google.cloud.artifactregistry_v1.types.Rule): + The rule that replaces the resource + on the server. + + This corresponds to the ``rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. + + """ + # 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([rule, 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, gda_rule.UpdateRuleRequest): + request = gda_rule.UpdateRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if rule is not None: + request.rule = rule + 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_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("rule.name", request.rule.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_rule( + self, + request: Optional[Union[rule.DeleteRuleRequest, 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]] = (), + ) -> None: + r"""Deletes a rule. + + .. 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_delete_rule(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.DeleteRuleRequest( + name="name_value", + ) + + # Make the request + client.delete_rule(request=request) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.DeleteRuleRequest, dict]): + The request object. The request to delete a rule. + name (str): + Required. The name of the rule to + delete. + + 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. + """ + # 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, rule.DeleteRuleRequest): + request = rule.DeleteRuleRequest(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.delete_rule] + + # 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),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + def set_iam_policy( + self, + request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> policy_pb2.Policy: + r"""Updates the IAM policy for a given resource. + + .. 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 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_set_iam_policy(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): + The request object. Request message for ``SetIamPolicy`` method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.iam.v1.policy_pb2.Policy: + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. + + A Policy is a collection of bindings. A binding binds + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** + + :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + + **YAML example:** + + :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + + For a description of IAM and its features, see the + [IAM + documentation](\ https://cloud.google.com/iam/docs/). + + """ + # Create or coerce a protobuf request object. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = iam_policy_pb2.SetIamPolicyRequest(**request) + elif not request: + # Null request, just make one. + request = iam_policy_pb2.SetIamPolicyRequest() + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.set_iam_policy] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_iam_policy( + self, + request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> policy_pb2.Policy: + r"""Gets the IAM policy for a given resource. + + .. 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 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_get_iam_policy(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): + The request object. Request message for ``GetIamPolicy`` method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.iam.v1.policy_pb2.Policy: + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. + + A Policy is a collection of bindings. A binding binds + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding can also specify a condition, which is a logical expression that allows access to a resource only if the expression evaluates to true. A condition can add @@ -4352,36 +5437,335 @@ def sample_set_iam_policy(): conditions in their IAM policies, see the [IAM documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - **JSON example:** + **JSON example:** + + :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + + **YAML example:** + + :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + + For a description of IAM and its features, see the + [IAM + documentation](\ https://cloud.google.com/iam/docs/). + + """ + # Create or coerce a protobuf request object. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = iam_policy_pb2.GetIamPolicyRequest(**request) + elif not request: + # Null request, just make one. + request = iam_policy_pb2.GetIamPolicyRequest() + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_iam_policy] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + # Done; return the response. + return response - **YAML example:** + def test_iam_permissions( + self, + request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> iam_policy_pb2.TestIamPermissionsResponse: + r"""Tests if the caller has a list of permissions on a + resource. - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + .. 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 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_test_iam_permissions(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): + The request object. Request message for ``TestIamPermissions`` method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: + Response message for TestIamPermissions method. + """ + # Create or coerce a protobuf request object. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = iam_policy_pb2.TestIamPermissionsRequest(**request) + elif not request: + # Null request, just make one. + request = iam_policy_pb2.TestIamPermissionsRequest() + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_project_settings( + self, + request: Optional[Union[settings.GetProjectSettingsRequest, 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]] = (), + ) -> settings.ProjectSettings: + r"""Retrieves the Settings 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_project_settings(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.GetProjectSettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_project_settings(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest, dict]): + The request object. Gets the redirection status for a + project. + name (str): + Required. The name of the + projectSettings 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.ProjectSettings: + The Artifact Registry settings 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, settings.GetProjectSettingsRequest): + request = settings.GetProjectSettingsRequest(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_project_settings] + + # 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),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_project_settings( + self, + request: Optional[Union[settings.UpdateProjectSettingsRequest, dict]] = None, + *, + project_settings: Optional[settings.ProjectSettings] = 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]] = (), + ) -> settings.ProjectSettings: + r"""Updates the Settings 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_project_settings(): + # Create a client + client = artifactregistry_v1.ArtifactRegistryClient() + + # Initialize request argument(s) + request = artifactregistry_v1.UpdateProjectSettingsRequest( + ) + + # Make the request + response = client.update_project_settings(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest, dict]): + The request object. Sets the settings of the project. + project_settings (google.cloud.artifactregistry_v1.types.ProjectSettings): + The project settings. + This corresponds to the ``project_settings`` 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. - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). + Returns: + google.cloud.artifactregistry_v1.types.ProjectSettings: + The Artifact Registry settings that + apply to a Project. """ # Create or coerce a protobuf request object. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.SetIamPolicyRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.SetIamPolicyRequest() + # - 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([project_settings, 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, settings.UpdateProjectSettingsRequest): + request = settings.UpdateProjectSettingsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project_settings is not None: + request.project_settings = project_settings + 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.set_iam_policy] + rpc = self._transport._wrapped_methods[self._transport.update_project_settings] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata( + (("project_settings.name", request.project_settings.name),) + ), ) # Validate the universe domain. @@ -4398,15 +5782,16 @@ def sample_set_iam_policy(): # Done; return the response. return response - def get_iam_policy( + def get_vpcsc_config( self, - request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, + 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]] = (), - ) -> policy_pb2.Policy: - r"""Gets the IAM policy for a given resource. + ) -> vpcsc_config.VPCSCConfig: + r"""Retrieves the VPCSC Config for the Project. .. code-block:: python @@ -4418,26 +5803,32 @@ def get_iam_policy( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_get_iam_policy(): + def sample_get_vpcsc_config(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", + request = artifactregistry_v1.GetVPCSCConfigRequest( + name="name_value", ) # Make the request - response = client.get_iam_policy(request=request) + response = client.get_vpcsc_config(request=request) # Handle the response print(response) Args: - request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): - The request object. Request message for ``GetIamPolicy`` method. + 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. @@ -4445,56 +5836,151 @@ def sample_get_iam_policy(): sent along with the request as metadata. Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. + google.cloud.artifactregistry_v1.types.VPCSCConfig: + The Artifact Registry VPC SC config + that apply to a Project. - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. + """ + # 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." + ) - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + 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 - **JSON example:** + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_vpcsc_config] - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + # 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),)), + ) - **YAML example:** + # Validate the universe domain. + self._validate_universe_domain() - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). + # 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. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.GetIamPolicyRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.GetIamPolicyRequest() + # - 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + 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.get_iam_policy] + 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((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata( + (("vpcsc_config.name", request.vpcsc_config.name),) + ), ) # Validate the universe domain. @@ -4511,16 +5997,17 @@ def sample_get_iam_policy(): # Done; return the response. return response - def test_iam_permissions( + def update_package( self, - request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, + request: Optional[Union[gda_package.UpdatePackageRequest, dict]] = None, *, + package: Optional[gda_package.Package] = 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]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Tests if the caller has a list of permissions on a - resource. + ) -> gda_package.Package: + r"""Updates a package. .. code-block:: python @@ -4532,27 +6019,39 @@ def test_iam_permissions( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_test_iam_permissions(): + def sample_update_package(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], + request = artifactregistry_v1.UpdatePackageRequest( ) # Make the request - response = client.test_iam_permissions(request=request) + response = client.update_package(request=request) # Handle the response print(response) Args: - request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): - The request object. Request message for ``TestIamPermissions`` method. + request (Union[google.cloud.artifactregistry_v1.types.UpdatePackageRequest, dict]): + The request object. The request to update a package. + package (google.cloud.artifactregistry_v1.types.Package): + The package that replaces the + resource on the server. + + This corresponds to the ``package`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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. @@ -4560,26 +6059,42 @@ def sample_test_iam_permissions(): sent along with the request as metadata. Returns: - google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: - Response message for TestIamPermissions method. + google.cloud.artifactregistry_v1.types.Package: + Packages are named collections of + versions. + """ # Create or coerce a protobuf request object. - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.TestIamPermissionsRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.TestIamPermissionsRequest() + # - 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([package, 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, gda_package.UpdatePackageRequest): + request = gda_package.UpdatePackageRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if package is not None: + request.package = package + 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.test_iam_permissions] + rpc = self._transport._wrapped_methods[self._transport.update_package] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata( + (("package.name", request.package.name),) + ), ) # Validate the universe domain. @@ -4596,16 +6111,16 @@ def sample_test_iam_permissions(): # Done; return the response. return response - def get_project_settings( + def list_attachments( self, - request: Optional[Union[settings.GetProjectSettingsRequest, dict]] = None, + request: Optional[Union[attachment.ListAttachmentsRequest, dict]] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> settings.ProjectSettings: - r"""Retrieves the Settings for the Project. + ) -> pagers.ListAttachmentsPager: + r"""Lists attachments. .. code-block:: python @@ -4618,30 +6133,31 @@ def get_project_settings( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_get_project_settings(): + def sample_list_attachments(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.GetProjectSettingsRequest( - name="name_value", + request = artifactregistry_v1.ListAttachmentsRequest( + parent="parent_value", ) # Make the request - response = client.get_project_settings(request=request) + page_result = client.list_attachments(request=request) # Handle the response - print(response) + for response in page_result: + print(response) Args: - request (Union[google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest, dict]): - The request object. Gets the redirection status for a - project. - name (str): - Required. The name of the - projectSettings resource. + request (Union[google.cloud.artifactregistry_v1.types.ListAttachmentsRequest, dict]): + The request object. The request to list attachments. + parent (str): + Required. The name of the parent + resource whose attachments will be + listed. - This corresponds to the ``name`` field + 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, @@ -4651,15 +6167,18 @@ def sample_get_project_settings(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.ProjectSettings: - The Artifact Registry settings that - apply to a Project. + google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListAttachmentsPager: + The response from listing + attachments. + 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([name]) + 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 " @@ -4668,21 +6187,21 @@ def sample_get_project_settings(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, settings.GetProjectSettingsRequest): - request = settings.GetProjectSettingsRequest(request) + if not isinstance(request, attachment.ListAttachmentsRequest): + request = attachment.ListAttachmentsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + 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.get_project_settings] + rpc = self._transport._wrapped_methods[self._transport.list_attachments] # 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),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -4696,20 +6215,30 @@ def sample_get_project_settings(): metadata=metadata, ) + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListAttachmentsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + # Done; return the response. return response - def update_project_settings( + def get_attachment( self, - request: Optional[Union[settings.UpdateProjectSettingsRequest, dict]] = None, + request: Optional[Union[attachment.GetAttachmentRequest, dict]] = None, *, - project_settings: Optional[settings.ProjectSettings] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> settings.ProjectSettings: - r"""Updates the Settings for the Project. + ) -> attachment.Attachment: + r"""Gets an attachment. .. code-block:: python @@ -4722,33 +6251,30 @@ def update_project_settings( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_update_project_settings(): + def sample_get_attachment(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.UpdateProjectSettingsRequest( + request = artifactregistry_v1.GetAttachmentRequest( + name="name_value", ) # Make the request - response = client.update_project_settings(request=request) + response = client.get_attachment(request=request) # Handle the response print(response) Args: - request (Union[google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest, dict]): - The request object. Sets the settings of the project. - project_settings (google.cloud.artifactregistry_v1.types.ProjectSettings): - The project settings. - This corresponds to the ``project_settings`` 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. + request (Union[google.cloud.artifactregistry_v1.types.GetAttachmentRequest, dict]): + The request object. The request to retrieve an + attachment. + name (str): + Required. The name of the attachment + to retrieve. - This corresponds to the ``update_mask`` field + 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, @@ -4758,15 +6284,18 @@ def sample_update_project_settings(): sent along with the request as metadata. Returns: - google.cloud.artifactregistry_v1.types.ProjectSettings: - The Artifact Registry settings that - apply to a Project. + google.cloud.artifactregistry_v1.types.Attachment: + An Attachment refers to additional + metadata that can be attached to + artifacts in Artifact Registry. An + attachment consists of one or more + files. """ # 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([project_settings, update_mask]) + 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 " @@ -4775,25 +6304,21 @@ def sample_update_project_settings(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, settings.UpdateProjectSettingsRequest): - request = settings.UpdateProjectSettingsRequest(request) + if not isinstance(request, attachment.GetAttachmentRequest): + request = attachment.GetAttachmentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_settings is not None: - request.project_settings = project_settings - if update_mask is not None: - request.update_mask = update_mask + 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.update_project_settings] + rpc = self._transport._wrapped_methods[self._transport.get_attachment] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("project_settings.name", request.project_settings.name),) - ), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -4810,16 +6335,20 @@ def sample_update_project_settings(): # Done; return the response. return response - def get_vpcsc_config( + def create_attachment( self, - request: Optional[Union[vpcsc_config.GetVPCSCConfigRequest, dict]] = None, + request: Optional[Union[gda_attachment.CreateAttachmentRequest, dict]] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, + attachment: Optional[gda_attachment.Attachment] = None, + attachment_id: 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. + ) -> operation.Operation: + r"""Creates an attachment. The returned Operation will + finish once the attachment has been created. Its + response will be the created attachment. .. code-block:: python @@ -4832,29 +6361,55 @@ def get_vpcsc_config( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_get_vpcsc_config(): + def sample_create_attachment(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.GetVPCSCConfigRequest( - name="name_value", + attachment = artifactregistry_v1.Attachment() + attachment.target = "target_value" + attachment.files = ['files_value1', 'files_value2'] + + request = artifactregistry_v1.CreateAttachmentRequest( + parent="parent_value", + attachment_id="attachment_id_value", + attachment=attachment, ) # Make the request - response = client.get_vpcsc_config(request=request) + operation = client.create_attachment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() # 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. + request (Union[google.cloud.artifactregistry_v1.types.CreateAttachmentRequest, dict]): + The request object. The request to create a new + attachment. + parent (str): + Required. The name of the parent + resource where the attachment will be + created. - This corresponds to the ``name`` field + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + attachment (google.cloud.artifactregistry_v1.types.Attachment): + Required. The attachment to be + created. + + This corresponds to the ``attachment`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + attachment_id (str): + Required. The attachment id to use + for this attachment. + + This corresponds to the ``attachment_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -4864,15 +6419,18 @@ def sample_get_vpcsc_config(): 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. + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.artifactregistry_v1.types.Attachment` An Attachment refers to additional metadata that can be attached to + artifacts in Artifact Registry. An attachment + consists of one or more files. """ # 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]) + has_flattened_params = any([parent, attachment, attachment_id]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " @@ -4881,21 +6439,25 @@ def sample_get_vpcsc_config(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, vpcsc_config.GetVPCSCConfigRequest): - request = vpcsc_config.GetVPCSCConfigRequest(request) + if not isinstance(request, gda_attachment.CreateAttachmentRequest): + request = gda_attachment.CreateAttachmentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent + if attachment is not None: + request.attachment = attachment + if attachment_id is not None: + request.attachment_id = attachment_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_vpcsc_config] + rpc = self._transport._wrapped_methods[self._transport.create_attachment] # 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),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -4909,22 +6471,29 @@ def sample_get_vpcsc_config(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + gda_attachment.Attachment, + metadata_type=service.OperationMetadata, + ) + # Done; return the response. return response - def update_vpcsc_config( + def delete_attachment( self, - request: Optional[ - Union[gda_vpcsc_config.UpdateVPCSCConfigRequest, dict] - ] = None, + request: Optional[Union[attachment.DeleteAttachmentRequest, dict]] = None, *, - vpcsc_config: Optional[gda_vpcsc_config.VPCSCConfig] = None, - update_mask: Optional[field_mask_pb2.FieldMask] = None, + name: Optional[str] = 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. + ) -> operation.Operation: + r"""Deletes an attachment. The returned Operation will finish once + the attachments has been deleted. It will not have any Operation + metadata and will return a ``google.protobuf.Empty`` response. .. code-block:: python @@ -4937,33 +6506,33 @@ def update_vpcsc_config( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import artifactregistry_v1 - def sample_update_vpcsc_config(): + def sample_delete_attachment(): # Create a client client = artifactregistry_v1.ArtifactRegistryClient() # Initialize request argument(s) - request = artifactregistry_v1.UpdateVPCSCConfigRequest( + request = artifactregistry_v1.DeleteAttachmentRequest( + name="name_value", ) # Make the request - response = client.update_vpcsc_config(request=request) + operation = client.delete_attachment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() # 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. + request (Union[google.cloud.artifactregistry_v1.types.DeleteAttachmentRequest, dict]): + The request object. The request to delete an attachment. + name (str): + Required. The name of the attachment + to delete. - This corresponds to the ``update_mask`` field + 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, @@ -4973,15 +6542,25 @@ def sample_update_vpcsc_config(): 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. + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } """ # 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]) + 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 " @@ -4990,25 +6569,21 @@ def sample_update_vpcsc_config(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, gda_vpcsc_config.UpdateVPCSCConfigRequest): - request = gda_vpcsc_config.UpdateVPCSCConfigRequest(request) + if not isinstance(request, attachment.DeleteAttachmentRequest): + request = attachment.DeleteAttachmentRequest(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 + 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.update_vpcsc_config] + rpc = self._transport._wrapped_methods[self._transport.delete_attachment] # 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),) - ), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -5022,6 +6597,14 @@ def sample_update_vpcsc_config(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=service.OperationMetadata, + ) + # Done; return the response. return response diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py index c8506d599e30..72859ed617b5 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py @@ -40,9 +40,11 @@ from google.cloud.artifactregistry_v1.types import ( artifact, + attachment, file, package, repository, + rule, tag, version, ) @@ -1414,3 +1416,307 @@ async def async_generator(): def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListRulesPager: + """A pager for iterating through ``list_rules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListRulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``rules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListRules`` requests and continue to iterate + through the ``rules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListRulesResponse` + 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[..., rule.ListRulesResponse], + request: rule.ListRulesRequest, + response: rule.ListRulesResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + 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.ListRulesRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListRulesResponse): + The initial response object. + 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. + """ + self._method = method + self._request = rule.ListRulesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[rule.ListRulesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[rule.Rule]: + for page in self.pages: + yield from page.rules + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListRulesAsyncPager: + """A pager for iterating through ``list_rules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListRulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``rules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListRules`` requests and continue to iterate + through the ``rules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListRulesResponse` + 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[rule.ListRulesResponse]], + request: rule.ListRulesRequest, + response: rule.ListRulesResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + 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.ListRulesRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListRulesResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): 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. + """ + self._method = method + self._request = rule.ListRulesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[rule.ListRulesResponse]: + 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, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[rule.Rule]: + async def async_generator(): + async for page in self.pages: + for response in page.rules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAttachmentsPager: + """A pager for iterating through ``list_attachments`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListAttachmentsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``attachments`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListAttachments`` requests and continue to iterate + through the ``attachments`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListAttachmentsResponse` + 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[..., attachment.ListAttachmentsResponse], + request: attachment.ListAttachmentsRequest, + response: attachment.ListAttachmentsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + 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.ListAttachmentsRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListAttachmentsResponse): + The initial response object. + 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. + """ + self._method = method + self._request = attachment.ListAttachmentsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[attachment.ListAttachmentsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[attachment.Attachment]: + for page in self.pages: + yield from page.attachments + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListAttachmentsAsyncPager: + """A pager for iterating through ``list_attachments`` requests. + + This class thinly wraps an initial + :class:`google.cloud.artifactregistry_v1.types.ListAttachmentsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``attachments`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListAttachments`` requests and continue to iterate + through the ``attachments`` field on the + corresponding responses. + + All the usual :class:`google.cloud.artifactregistry_v1.types.ListAttachmentsResponse` + 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[attachment.ListAttachmentsResponse]], + request: attachment.ListAttachmentsRequest, + response: attachment.ListAttachmentsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + 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.ListAttachmentsRequest): + The initial request object. + response (google.cloud.artifactregistry_v1.types.ListAttachmentsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): 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. + """ + self._method = method + self._request = attachment.ListAttachmentsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[attachment.ListAttachmentsResponse]: + 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, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[attachment.Attachment]: + async def async_generator(): + async for page in self.pages: + for response in page.attachments: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py index e7d8a85ab5ce..9bab91bc8c57 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/base.py @@ -30,14 +30,23 @@ from google.protobuf import empty_pb2 # type: ignore 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 apt_artifact, artifact +from google.cloud.artifactregistry_v1.types import attachment +from google.cloud.artifactregistry_v1.types import attachment as gda_attachment +from google.cloud.artifactregistry_v1.types import file +from google.cloud.artifactregistry_v1.types import file as gda_file +from google.cloud.artifactregistry_v1.types import package +from google.cloud.artifactregistry_v1.types import package as gda_package 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 rule +from google.cloud.artifactregistry_v1.types import rule as gda_rule 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 +from google.cloud.artifactregistry_v1.types import version as gda_version from google.cloud.artifactregistry_v1.types import vpcsc_config from google.cloud.artifactregistry_v1.types import yum_artifact @@ -255,6 +264,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.update_version: gapic_v1.method.wrap_method( + self.update_version, + default_timeout=None, + client_info=client_info, + ), self.list_files: gapic_v1.method.wrap_method( self.list_files, default_timeout=None, @@ -265,6 +279,16 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.delete_file: gapic_v1.method.wrap_method( + self.delete_file, + default_timeout=None, + client_info=client_info, + ), + self.update_file: gapic_v1.method.wrap_method( + self.update_file, + default_timeout=None, + client_info=client_info, + ), self.list_tags: gapic_v1.method.wrap_method( self.list_tags, default_timeout=None, @@ -290,6 +314,31 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_rule: gapic_v1.method.wrap_method( + self.create_rule, + default_timeout=None, + client_info=client_info, + ), + self.list_rules: gapic_v1.method.wrap_method( + self.list_rules, + default_timeout=None, + client_info=client_info, + ), + self.get_rule: gapic_v1.method.wrap_method( + self.get_rule, + default_timeout=None, + client_info=client_info, + ), + self.update_rule: gapic_v1.method.wrap_method( + self.update_rule, + default_timeout=None, + client_info=client_info, + ), + self.delete_rule: gapic_v1.method.wrap_method( + self.delete_rule, + default_timeout=None, + client_info=client_info, + ), self.set_iam_policy: gapic_v1.method.wrap_method( self.set_iam_policy, default_timeout=None, @@ -325,6 +374,31 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.update_package: gapic_v1.method.wrap_method( + self.update_package, + default_timeout=None, + client_info=client_info, + ), + self.list_attachments: gapic_v1.method.wrap_method( + self.list_attachments, + default_timeout=None, + client_info=client_info, + ), + self.get_attachment: gapic_v1.method.wrap_method( + self.get_attachment, + default_timeout=None, + client_info=client_info, + ), + self.create_attachment: gapic_v1.method.wrap_method( + self.create_attachment, + default_timeout=None, + client_info=client_info, + ), + self.delete_attachment: gapic_v1.method.wrap_method( + self.delete_attachment, + default_timeout=None, + client_info=client_info, + ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, @@ -567,6 +641,15 @@ def batch_delete_versions( ]: raise NotImplementedError() + @property + def update_version( + self, + ) -> Callable[ + [gda_version.UpdateVersionRequest], + Union[gda_version.Version, Awaitable[gda_version.Version]], + ]: + raise NotImplementedError() + @property def list_files( self, @@ -582,6 +665,23 @@ def get_file( ) -> Callable[[file.GetFileRequest], Union[file.File, Awaitable[file.File]]]: raise NotImplementedError() + @property + def delete_file( + self, + ) -> Callable[ + [file.DeleteFileRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def update_file( + self, + ) -> Callable[ + [gda_file.UpdateFileRequest], Union[gda_file.File, Awaitable[gda_file.File]] + ]: + raise NotImplementedError() + @property def list_tags( self, @@ -621,6 +721,45 @@ def delete_tag( ]: raise NotImplementedError() + @property + def create_rule( + self, + ) -> Callable[ + [gda_rule.CreateRuleRequest], Union[gda_rule.Rule, Awaitable[gda_rule.Rule]] + ]: + raise NotImplementedError() + + @property + def list_rules( + self, + ) -> Callable[ + [rule.ListRulesRequest], + Union[rule.ListRulesResponse, Awaitable[rule.ListRulesResponse]], + ]: + raise NotImplementedError() + + @property + def get_rule( + self, + ) -> Callable[[rule.GetRuleRequest], Union[rule.Rule, Awaitable[rule.Rule]]]: + raise NotImplementedError() + + @property + def update_rule( + self, + ) -> Callable[ + [gda_rule.UpdateRuleRequest], Union[gda_rule.Rule, Awaitable[gda_rule.Rule]] + ]: + raise NotImplementedError() + + @property + def delete_rule( + self, + ) -> Callable[ + [rule.DeleteRuleRequest], Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]] + ]: + raise NotImplementedError() + @property def set_iam_policy( self, @@ -687,6 +826,54 @@ def update_vpcsc_config( ]: raise NotImplementedError() + @property + def update_package( + self, + ) -> Callable[ + [gda_package.UpdatePackageRequest], + Union[gda_package.Package, Awaitable[gda_package.Package]], + ]: + raise NotImplementedError() + + @property + def list_attachments( + self, + ) -> Callable[ + [attachment.ListAttachmentsRequest], + Union[ + attachment.ListAttachmentsResponse, + Awaitable[attachment.ListAttachmentsResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_attachment( + self, + ) -> Callable[ + [attachment.GetAttachmentRequest], + Union[attachment.Attachment, Awaitable[attachment.Attachment]], + ]: + raise NotImplementedError() + + @property + def create_attachment( + self, + ) -> Callable[ + [gda_attachment.CreateAttachmentRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def delete_attachment( + self, + ) -> Callable[ + [attachment.DeleteAttachmentRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def get_operation( self, diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py index a7029edd8511..eed5d0fde726 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py @@ -27,14 +27,23 @@ from google.protobuf import empty_pb2 # type: ignore 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 apt_artifact, artifact +from google.cloud.artifactregistry_v1.types import attachment +from google.cloud.artifactregistry_v1.types import attachment as gda_attachment +from google.cloud.artifactregistry_v1.types import file +from google.cloud.artifactregistry_v1.types import file as gda_file +from google.cloud.artifactregistry_v1.types import package +from google.cloud.artifactregistry_v1.types import package as gda_package 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 rule +from google.cloud.artifactregistry_v1.types import rule as gda_rule 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 +from google.cloud.artifactregistry_v1.types import version as gda_version from google.cloud.artifactregistry_v1.types import vpcsc_config from google.cloud.artifactregistry_v1.types import yum_artifact @@ -870,6 +879,32 @@ def batch_delete_versions( ) return self._stubs["batch_delete_versions"] + @property + def update_version( + self, + ) -> Callable[[gda_version.UpdateVersionRequest], gda_version.Version]: + r"""Return a callable for the update version method over gRPC. + + Updates a version. + + Returns: + Callable[[~.UpdateVersionRequest], + ~.Version]: + 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_version" not in self._stubs: + self._stubs["update_version"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVersion", + request_serializer=gda_version.UpdateVersionRequest.serialize, + response_deserializer=gda_version.Version.deserialize, + ) + return self._stubs["update_version"] + @property def list_files(self) -> Callable[[file.ListFilesRequest], file.ListFilesResponse]: r"""Return a callable for the list files method over gRPC. @@ -918,6 +953,58 @@ def get_file(self) -> Callable[[file.GetFileRequest], file.File]: ) return self._stubs["get_file"] + @property + def delete_file( + self, + ) -> Callable[[file.DeleteFileRequest], operations_pb2.Operation]: + r"""Return a callable for the delete file method over gRPC. + + Deletes a file and all of its content. It is only + allowed on generic repositories. The returned operation + will complete once the file has been deleted. + + Returns: + Callable[[~.DeleteFileRequest], + ~.Operation]: + 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 "delete_file" not in self._stubs: + self._stubs["delete_file"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteFile", + request_serializer=file.DeleteFileRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_file"] + + @property + def update_file(self) -> Callable[[gda_file.UpdateFileRequest], gda_file.File]: + r"""Return a callable for the update file method over gRPC. + + Updates a file. + + Returns: + Callable[[~.UpdateFileRequest], + ~.File]: + 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_file" not in self._stubs: + self._stubs["update_file"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateFile", + request_serializer=gda_file.UpdateFileRequest.serialize, + response_deserializer=gda_file.File.deserialize, + ) + return self._stubs["update_file"] + @property def list_tags(self) -> Callable[[tag.ListTagsRequest], tag.ListTagsResponse]: r"""Return a callable for the list tags method over gRPC. @@ -1038,6 +1125,126 @@ def delete_tag(self) -> Callable[[tag.DeleteTagRequest], empty_pb2.Empty]: ) return self._stubs["delete_tag"] + @property + def create_rule(self) -> Callable[[gda_rule.CreateRuleRequest], gda_rule.Rule]: + r"""Return a callable for the create rule method over gRPC. + + Creates a rule. + + Returns: + Callable[[~.CreateRuleRequest], + ~.Rule]: + 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 "create_rule" not in self._stubs: + self._stubs["create_rule"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRule", + request_serializer=gda_rule.CreateRuleRequest.serialize, + response_deserializer=gda_rule.Rule.deserialize, + ) + return self._stubs["create_rule"] + + @property + def list_rules(self) -> Callable[[rule.ListRulesRequest], rule.ListRulesResponse]: + r"""Return a callable for the list rules method over gRPC. + + Lists rules. + + Returns: + Callable[[~.ListRulesRequest], + ~.ListRulesResponse]: + 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_rules" not in self._stubs: + self._stubs["list_rules"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRules", + request_serializer=rule.ListRulesRequest.serialize, + response_deserializer=rule.ListRulesResponse.deserialize, + ) + return self._stubs["list_rules"] + + @property + def get_rule(self) -> Callable[[rule.GetRuleRequest], rule.Rule]: + r"""Return a callable for the get rule method over gRPC. + + Gets a rule. + + Returns: + Callable[[~.GetRuleRequest], + ~.Rule]: + 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_rule" not in self._stubs: + self._stubs["get_rule"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRule", + request_serializer=rule.GetRuleRequest.serialize, + response_deserializer=rule.Rule.deserialize, + ) + return self._stubs["get_rule"] + + @property + def update_rule(self) -> Callable[[gda_rule.UpdateRuleRequest], gda_rule.Rule]: + r"""Return a callable for the update rule method over gRPC. + + Updates a rule. + + Returns: + Callable[[~.UpdateRuleRequest], + ~.Rule]: + 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_rule" not in self._stubs: + self._stubs["update_rule"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRule", + request_serializer=gda_rule.UpdateRuleRequest.serialize, + response_deserializer=gda_rule.Rule.deserialize, + ) + return self._stubs["update_rule"] + + @property + def delete_rule(self) -> Callable[[rule.DeleteRuleRequest], empty_pb2.Empty]: + r"""Return a callable for the delete rule method over gRPC. + + Deletes a rule. + + Returns: + Callable[[~.DeleteRuleRequest], + ~.Empty]: + 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 "delete_rule" not in self._stubs: + self._stubs["delete_rule"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRule", + request_serializer=rule.DeleteRuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_rule"] + @property def set_iam_policy( self, @@ -1226,6 +1433,142 @@ def update_vpcsc_config( ) return self._stubs["update_vpcsc_config"] + @property + def update_package( + self, + ) -> Callable[[gda_package.UpdatePackageRequest], gda_package.Package]: + r"""Return a callable for the update package method over gRPC. + + Updates a package. + + Returns: + Callable[[~.UpdatePackageRequest], + ~.Package]: + 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_package" not in self._stubs: + self._stubs["update_package"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdatePackage", + request_serializer=gda_package.UpdatePackageRequest.serialize, + response_deserializer=gda_package.Package.deserialize, + ) + return self._stubs["update_package"] + + @property + def list_attachments( + self, + ) -> Callable[ + [attachment.ListAttachmentsRequest], attachment.ListAttachmentsResponse + ]: + r"""Return a callable for the list attachments method over gRPC. + + Lists attachments. + + Returns: + Callable[[~.ListAttachmentsRequest], + ~.ListAttachmentsResponse]: + 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_attachments" not in self._stubs: + self._stubs["list_attachments"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListAttachments", + request_serializer=attachment.ListAttachmentsRequest.serialize, + response_deserializer=attachment.ListAttachmentsResponse.deserialize, + ) + return self._stubs["list_attachments"] + + @property + def get_attachment( + self, + ) -> Callable[[attachment.GetAttachmentRequest], attachment.Attachment]: + r"""Return a callable for the get attachment method over gRPC. + + Gets an attachment. + + Returns: + Callable[[~.GetAttachmentRequest], + ~.Attachment]: + 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_attachment" not in self._stubs: + self._stubs["get_attachment"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetAttachment", + request_serializer=attachment.GetAttachmentRequest.serialize, + response_deserializer=attachment.Attachment.deserialize, + ) + return self._stubs["get_attachment"] + + @property + def create_attachment( + self, + ) -> Callable[[gda_attachment.CreateAttachmentRequest], operations_pb2.Operation]: + r"""Return a callable for the create attachment method over gRPC. + + Creates an attachment. The returned Operation will + finish once the attachment has been created. Its + response will be the created attachment. + + Returns: + Callable[[~.CreateAttachmentRequest], + ~.Operation]: + 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 "create_attachment" not in self._stubs: + self._stubs["create_attachment"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateAttachment", + request_serializer=gda_attachment.CreateAttachmentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_attachment"] + + @property + def delete_attachment( + self, + ) -> Callable[[attachment.DeleteAttachmentRequest], operations_pb2.Operation]: + r"""Return a callable for the delete attachment method over gRPC. + + Deletes an attachment. The returned Operation will finish once + the attachments has been deleted. It will not have any Operation + metadata and will return a ``google.protobuf.Empty`` response. + + Returns: + Callable[[~.DeleteAttachmentRequest], + ~.Operation]: + 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 "delete_attachment" not in self._stubs: + self._stubs["delete_attachment"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteAttachment", + request_serializer=attachment.DeleteAttachmentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_attachment"] + def close(self): self.grpc_channel.close() diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py index 5820af0852fd..0cb0f05886c1 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py @@ -30,14 +30,23 @@ import grpc # type: ignore 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 apt_artifact, artifact +from google.cloud.artifactregistry_v1.types import attachment +from google.cloud.artifactregistry_v1.types import attachment as gda_attachment +from google.cloud.artifactregistry_v1.types import file +from google.cloud.artifactregistry_v1.types import file as gda_file +from google.cloud.artifactregistry_v1.types import package +from google.cloud.artifactregistry_v1.types import package as gda_package 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 rule +from google.cloud.artifactregistry_v1.types import rule as gda_rule 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 +from google.cloud.artifactregistry_v1.types import version as gda_version from google.cloud.artifactregistry_v1.types import vpcsc_config from google.cloud.artifactregistry_v1.types import yum_artifact @@ -909,6 +918,32 @@ def batch_delete_versions( ) return self._stubs["batch_delete_versions"] + @property + def update_version( + self, + ) -> Callable[[gda_version.UpdateVersionRequest], Awaitable[gda_version.Version]]: + r"""Return a callable for the update version method over gRPC. + + Updates a version. + + Returns: + Callable[[~.UpdateVersionRequest], + Awaitable[~.Version]]: + 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_version" not in self._stubs: + self._stubs["update_version"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVersion", + request_serializer=gda_version.UpdateVersionRequest.serialize, + response_deserializer=gda_version.Version.deserialize, + ) + return self._stubs["update_version"] + @property def list_files( self, @@ -959,6 +994,60 @@ def get_file(self) -> Callable[[file.GetFileRequest], Awaitable[file.File]]: ) return self._stubs["get_file"] + @property + def delete_file( + self, + ) -> Callable[[file.DeleteFileRequest], Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete file method over gRPC. + + Deletes a file and all of its content. It is only + allowed on generic repositories. The returned operation + will complete once the file has been deleted. + + Returns: + Callable[[~.DeleteFileRequest], + Awaitable[~.Operation]]: + 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 "delete_file" not in self._stubs: + self._stubs["delete_file"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteFile", + request_serializer=file.DeleteFileRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_file"] + + @property + def update_file( + self, + ) -> Callable[[gda_file.UpdateFileRequest], Awaitable[gda_file.File]]: + r"""Return a callable for the update file method over gRPC. + + Updates a file. + + Returns: + Callable[[~.UpdateFileRequest], + Awaitable[~.File]]: + 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_file" not in self._stubs: + self._stubs["update_file"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateFile", + request_serializer=gda_file.UpdateFileRequest.serialize, + response_deserializer=gda_file.File.deserialize, + ) + return self._stubs["update_file"] + @property def list_tags( self, @@ -1087,6 +1176,134 @@ def delete_tag( ) return self._stubs["delete_tag"] + @property + def create_rule( + self, + ) -> Callable[[gda_rule.CreateRuleRequest], Awaitable[gda_rule.Rule]]: + r"""Return a callable for the create rule method over gRPC. + + Creates a rule. + + Returns: + Callable[[~.CreateRuleRequest], + Awaitable[~.Rule]]: + 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 "create_rule" not in self._stubs: + self._stubs["create_rule"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRule", + request_serializer=gda_rule.CreateRuleRequest.serialize, + response_deserializer=gda_rule.Rule.deserialize, + ) + return self._stubs["create_rule"] + + @property + def list_rules( + self, + ) -> Callable[[rule.ListRulesRequest], Awaitable[rule.ListRulesResponse]]: + r"""Return a callable for the list rules method over gRPC. + + Lists rules. + + Returns: + Callable[[~.ListRulesRequest], + Awaitable[~.ListRulesResponse]]: + 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_rules" not in self._stubs: + self._stubs["list_rules"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRules", + request_serializer=rule.ListRulesRequest.serialize, + response_deserializer=rule.ListRulesResponse.deserialize, + ) + return self._stubs["list_rules"] + + @property + def get_rule(self) -> Callable[[rule.GetRuleRequest], Awaitable[rule.Rule]]: + r"""Return a callable for the get rule method over gRPC. + + Gets a rule. + + Returns: + Callable[[~.GetRuleRequest], + Awaitable[~.Rule]]: + 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_rule" not in self._stubs: + self._stubs["get_rule"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRule", + request_serializer=rule.GetRuleRequest.serialize, + response_deserializer=rule.Rule.deserialize, + ) + return self._stubs["get_rule"] + + @property + def update_rule( + self, + ) -> Callable[[gda_rule.UpdateRuleRequest], Awaitable[gda_rule.Rule]]: + r"""Return a callable for the update rule method over gRPC. + + Updates a rule. + + Returns: + Callable[[~.UpdateRuleRequest], + Awaitable[~.Rule]]: + 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_rule" not in self._stubs: + self._stubs["update_rule"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRule", + request_serializer=gda_rule.UpdateRuleRequest.serialize, + response_deserializer=gda_rule.Rule.deserialize, + ) + return self._stubs["update_rule"] + + @property + def delete_rule( + self, + ) -> Callable[[rule.DeleteRuleRequest], Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete rule method over gRPC. + + Deletes a rule. + + Returns: + Callable[[~.DeleteRuleRequest], + Awaitable[~.Empty]]: + 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 "delete_rule" not in self._stubs: + self._stubs["delete_rule"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRule", + request_serializer=rule.DeleteRuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_rule"] + @property def set_iam_policy( self, @@ -1282,6 +1499,147 @@ def update_vpcsc_config( ) return self._stubs["update_vpcsc_config"] + @property + def update_package( + self, + ) -> Callable[[gda_package.UpdatePackageRequest], Awaitable[gda_package.Package]]: + r"""Return a callable for the update package method over gRPC. + + Updates a package. + + Returns: + Callable[[~.UpdatePackageRequest], + Awaitable[~.Package]]: + 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_package" not in self._stubs: + self._stubs["update_package"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdatePackage", + request_serializer=gda_package.UpdatePackageRequest.serialize, + response_deserializer=gda_package.Package.deserialize, + ) + return self._stubs["update_package"] + + @property + def list_attachments( + self, + ) -> Callable[ + [attachment.ListAttachmentsRequest], + Awaitable[attachment.ListAttachmentsResponse], + ]: + r"""Return a callable for the list attachments method over gRPC. + + Lists attachments. + + Returns: + Callable[[~.ListAttachmentsRequest], + Awaitable[~.ListAttachmentsResponse]]: + 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_attachments" not in self._stubs: + self._stubs["list_attachments"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListAttachments", + request_serializer=attachment.ListAttachmentsRequest.serialize, + response_deserializer=attachment.ListAttachmentsResponse.deserialize, + ) + return self._stubs["list_attachments"] + + @property + def get_attachment( + self, + ) -> Callable[[attachment.GetAttachmentRequest], Awaitable[attachment.Attachment]]: + r"""Return a callable for the get attachment method over gRPC. + + Gets an attachment. + + Returns: + Callable[[~.GetAttachmentRequest], + Awaitable[~.Attachment]]: + 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_attachment" not in self._stubs: + self._stubs["get_attachment"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetAttachment", + request_serializer=attachment.GetAttachmentRequest.serialize, + response_deserializer=attachment.Attachment.deserialize, + ) + return self._stubs["get_attachment"] + + @property + def create_attachment( + self, + ) -> Callable[ + [gda_attachment.CreateAttachmentRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the create attachment method over gRPC. + + Creates an attachment. The returned Operation will + finish once the attachment has been created. Its + response will be the created attachment. + + Returns: + Callable[[~.CreateAttachmentRequest], + Awaitable[~.Operation]]: + 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 "create_attachment" not in self._stubs: + self._stubs["create_attachment"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateAttachment", + request_serializer=gda_attachment.CreateAttachmentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_attachment"] + + @property + def delete_attachment( + self, + ) -> Callable[ + [attachment.DeleteAttachmentRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the delete attachment method over gRPC. + + Deletes an attachment. The returned Operation will finish once + the attachments has been deleted. It will not have any Operation + metadata and will return a ``google.protobuf.Empty`` response. + + Returns: + Callable[[~.DeleteAttachmentRequest], + Awaitable[~.Operation]]: + 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 "delete_attachment" not in self._stubs: + self._stubs["delete_attachment"] = self.grpc_channel.unary_unary( + "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteAttachment", + request_serializer=attachment.DeleteAttachmentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_attachment"] + def _prep_wrapped_messages(self, client_info): """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" self._wrapped_methods = { @@ -1395,6 +1753,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.update_version: self._wrap_method( + self.update_version, + default_timeout=None, + client_info=client_info, + ), self.list_files: self._wrap_method( self.list_files, default_timeout=None, @@ -1405,6 +1768,16 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.delete_file: self._wrap_method( + self.delete_file, + default_timeout=None, + client_info=client_info, + ), + self.update_file: self._wrap_method( + self.update_file, + default_timeout=None, + client_info=client_info, + ), self.list_tags: self._wrap_method( self.list_tags, default_timeout=None, @@ -1430,6 +1803,31 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_rule: self._wrap_method( + self.create_rule, + default_timeout=None, + client_info=client_info, + ), + self.list_rules: self._wrap_method( + self.list_rules, + default_timeout=None, + client_info=client_info, + ), + self.get_rule: self._wrap_method( + self.get_rule, + default_timeout=None, + client_info=client_info, + ), + self.update_rule: self._wrap_method( + self.update_rule, + default_timeout=None, + client_info=client_info, + ), + self.delete_rule: self._wrap_method( + self.delete_rule, + default_timeout=None, + client_info=client_info, + ), self.set_iam_policy: self._wrap_method( self.set_iam_policy, default_timeout=None, @@ -1465,6 +1863,31 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.update_package: self._wrap_method( + self.update_package, + default_timeout=None, + client_info=client_info, + ), + self.list_attachments: self._wrap_method( + self.list_attachments, + default_timeout=None, + client_info=client_info, + ), + self.get_attachment: self._wrap_method( + self.get_attachment, + default_timeout=None, + client_info=client_info, + ), + self.create_attachment: self._wrap_method( + self.create_attachment, + default_timeout=None, + client_info=client_info, + ), + self.delete_attachment: self._wrap_method( + self.delete_attachment, + default_timeout=None, + client_info=client_info, + ), self.get_location: self._wrap_method( self.get_location, default_timeout=None, diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py index 3189527330cd..b7b5058680eb 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py @@ -32,14 +32,23 @@ from google.protobuf import json_format from requests import __version__ as requests_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 apt_artifact, artifact +from google.cloud.artifactregistry_v1.types import attachment +from google.cloud.artifactregistry_v1.types import attachment as gda_attachment +from google.cloud.artifactregistry_v1.types import file +from google.cloud.artifactregistry_v1.types import file as gda_file +from google.cloud.artifactregistry_v1.types import package +from google.cloud.artifactregistry_v1.types import package as gda_package 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 rule +from google.cloud.artifactregistry_v1.types import rule as gda_rule 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 +from google.cloud.artifactregistry_v1.types import version as gda_version from google.cloud.artifactregistry_v1.types import vpcsc_config from google.cloud.artifactregistry_v1.types import yum_artifact @@ -82,6 +91,14 @@ def post_batch_delete_versions(self, response): logging.log(f"Received response: {response}") return response + def pre_create_attachment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_attachment(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_repository(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -90,6 +107,14 @@ def post_create_repository(self, response): logging.log(f"Received response: {response}") return response + def pre_create_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_rule(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_tag(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -98,6 +123,22 @@ def post_create_tag(self, response): logging.log(f"Received response: {response}") return response + def pre_delete_attachment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_attachment(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_file(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_file(self, response): + logging.log(f"Received response: {response}") + return response + def pre_delete_package(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -114,6 +155,10 @@ def post_delete_repository(self, response): logging.log(f"Received response: {response}") return response + def pre_delete_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + def pre_delete_tag(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -126,6 +171,14 @@ def post_delete_version(self, response): logging.log(f"Received response: {response}") return response + def pre_get_attachment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_attachment(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_docker_image(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -198,6 +251,14 @@ def post_get_repository(self, response): logging.log(f"Received response: {response}") return response + def pre_get_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_rule(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_tag(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -238,6 +299,14 @@ def post_import_yum_artifacts(self, response): logging.log(f"Received response: {response}") return response + def pre_list_attachments(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_attachments(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_docker_images(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -294,6 +363,14 @@ def post_list_repositories(self, response): logging.log(f"Received response: {response}") return response + def pre_list_rules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_rules(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_tags(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -326,6 +403,22 @@ def post_test_iam_permissions(self, response): logging.log(f"Received response: {response}") return response + def pre_update_file(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_file(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_package(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_package(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_project_settings(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -342,6 +435,14 @@ def post_update_repository(self, response): logging.log(f"Received response: {response}") return response + def pre_update_rule(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_rule(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_tag(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -350,6 +451,14 @@ def post_update_tag(self, response): logging.log(f"Received response: {response}") return response + def pre_update_version(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_version(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_vpcsc_config(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -387,6 +496,29 @@ def post_batch_delete_versions( """ return response + def pre_create_attachment( + self, + request: gda_attachment.CreateAttachmentRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[gda_attachment.CreateAttachmentRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_attachment + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_create_attachment( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_attachment + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_create_repository( self, request: gda_repository.CreateRepositoryRequest, @@ -410,6 +542,25 @@ def post_create_repository( """ return response + def pre_create_rule( + self, request: gda_rule.CreateRuleRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[gda_rule.CreateRuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_create_rule(self, response: gda_rule.Rule) -> gda_rule.Rule: + """Post-rpc interceptor for create_rule + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_create_tag( self, request: gda_tag.CreateTagRequest, metadata: Sequence[Tuple[str, str]] ) -> Tuple[gda_tag.CreateTagRequest, Sequence[Tuple[str, str]]]: @@ -429,6 +580,50 @@ def post_create_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: """ return response + def pre_delete_attachment( + self, + request: attachment.DeleteAttachmentRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[attachment.DeleteAttachmentRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_attachment + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_delete_attachment( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_attachment + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + + def pre_delete_file( + self, request: file.DeleteFileRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[file.DeleteFileRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_file + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_delete_file( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_file + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_delete_package( self, request: package.DeletePackageRequest, metadata: Sequence[Tuple[str, str]] ) -> Tuple[package.DeletePackageRequest, Sequence[Tuple[str, str]]]: @@ -473,6 +668,16 @@ def post_delete_repository( """ return response + def pre_delete_rule( + self, request: rule.DeleteRuleRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[rule.DeleteRuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + def pre_delete_tag( self, request: tag.DeleteTagRequest, metadata: Sequence[Tuple[str, str]] ) -> Tuple[tag.DeleteTagRequest, Sequence[Tuple[str, str]]]: @@ -504,6 +709,29 @@ def post_delete_version( """ return response + def pre_get_attachment( + self, + request: attachment.GetAttachmentRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[attachment.GetAttachmentRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_attachment + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_get_attachment( + self, response: attachment.Attachment + ) -> attachment.Attachment: + """Post-rpc interceptor for get_attachment + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_get_docker_image( self, request: artifact.GetDockerImageRequest, @@ -701,6 +929,25 @@ def post_get_repository( """ return response + def pre_get_rule( + self, request: rule.GetRuleRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[rule.GetRuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_get_rule(self, response: rule.Rule) -> rule.Rule: + """Post-rpc interceptor for get_rule + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_get_tag( self, request: tag.GetTagRequest, metadata: Sequence[Tuple[str, str]] ) -> Tuple[tag.GetTagRequest, Sequence[Tuple[str, str]]]: @@ -808,6 +1055,29 @@ def post_import_yum_artifacts( """ return response + def pre_list_attachments( + self, + request: attachment.ListAttachmentsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[attachment.ListAttachmentsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_attachments + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_list_attachments( + self, response: attachment.ListAttachmentsResponse + ) -> attachment.ListAttachmentsResponse: + """Post-rpc interceptor for list_attachments + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_list_docker_images( self, request: artifact.ListDockerImagesRequest, @@ -965,6 +1235,27 @@ def post_list_repositories( """ return response + def pre_list_rules( + self, request: rule.ListRulesRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[rule.ListRulesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_rules + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_list_rules( + self, response: rule.ListRulesResponse + ) -> rule.ListRulesResponse: + """Post-rpc interceptor for list_rules + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_list_tags( self, request: tag.ListTagsRequest, metadata: Sequence[Tuple[str, str]] ) -> Tuple[tag.ListTagsRequest, Sequence[Tuple[str, str]]]: @@ -1049,6 +1340,46 @@ def post_test_iam_permissions( """ return response + def pre_update_file( + self, request: gda_file.UpdateFileRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[gda_file.UpdateFileRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_file + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_update_file(self, response: gda_file.File) -> gda_file.File: + """Post-rpc interceptor for update_file + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + + def pre_update_package( + self, + request: gda_package.UpdatePackageRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[gda_package.UpdatePackageRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_package + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_update_package(self, response: gda_package.Package) -> gda_package.Package: + """Post-rpc interceptor for update_package + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_update_project_settings( self, request: settings.UpdateProjectSettingsRequest, @@ -1095,6 +1426,25 @@ def post_update_repository( """ return response + def pre_update_rule( + self, request: gda_rule.UpdateRuleRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[gda_rule.UpdateRuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_update_rule(self, response: gda_rule.Rule) -> gda_rule.Rule: + """Post-rpc interceptor for update_rule + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_update_tag( self, request: gda_tag.UpdateTagRequest, metadata: Sequence[Tuple[str, str]] ) -> Tuple[gda_tag.UpdateTagRequest, Sequence[Tuple[str, str]]]: @@ -1114,6 +1464,27 @@ def post_update_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: """ return response + def pre_update_version( + self, + request: gda_version.UpdateVersionRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[gda_version.UpdateVersionRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_version + + Override in a subclass to manipulate the request or metadata + before they are sent to the ArtifactRegistry server. + """ + return request, metadata + + def post_update_version(self, response: gda_version.Version) -> gda_version.Version: + """Post-rpc interceptor for update_version + + Override in a subclass to manipulate the response + after it is returned by the ArtifactRegistry server but before + it is returned to user code. + """ + return response + def pre_update_vpcsc_config( self, request: gda_vpcsc_config.UpdateVPCSCConfigRequest, @@ -1439,7 +1810,106 @@ def __call__( resp = self._interceptor.post_batch_delete_versions(resp) return resp - class _CreateRepository( + class _CreateAttachment( + _BaseArtifactRegistryRestTransport._BaseCreateAttachment, + ArtifactRegistryRestStub, + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.CreateAttachment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: gda_attachment.CreateAttachmentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the create attachment method over HTTP. + + Args: + request (~.gda_attachment.CreateAttachmentRequest): + The request object. The request to create a new + attachment. + 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: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_http_options() + ) + request, metadata = self._interceptor.pre_create_attachment( + request, metadata + ) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_transcoded_request( + http_options, request + ) + + body = _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._CreateAttachment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_attachment(resp) + return resp + + class _CreateRepository( _BaseArtifactRegistryRestTransport._BaseCreateRepository, ArtifactRegistryRestStub, ): @@ -1538,6 +2008,106 @@ def __call__( resp = self._interceptor.post_create_repository(resp) return resp + class _CreateRule( + _BaseArtifactRegistryRestTransport._BaseCreateRule, ArtifactRegistryRestStub + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.CreateRule") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: gda_rule.CreateRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gda_rule.Rule: + r"""Call the create rule method over HTTP. + + Args: + request (~.gda_rule.CreateRuleRequest): + The request object. The request to create a new rule. + 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: + ~.gda_rule.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseCreateRule._get_http_options() + ) + request, metadata = self._interceptor.pre_create_rule(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateRule._get_transcoded_request( + http_options, request + ) + + body = _BaseArtifactRegistryRestTransport._BaseCreateRule._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseCreateRule._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._CreateRule._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = gda_rule.Rule() + pb_resp = gda_rule.Rule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_rule(resp) + return resp + class _CreateTag( _BaseArtifactRegistryRestTransport._BaseCreateTag, ArtifactRegistryRestStub ): @@ -1635,6 +2205,187 @@ def __call__( resp = self._interceptor.post_create_tag(resp) return resp + class _DeleteAttachment( + _BaseArtifactRegistryRestTransport._BaseDeleteAttachment, + ArtifactRegistryRestStub, + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.DeleteAttachment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: attachment.DeleteAttachmentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete attachment method over HTTP. + + Args: + request (~.attachment.DeleteAttachmentRequest): + The request object. The request to delete an attachment. + 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: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_attachment( + request, metadata + ) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._DeleteAttachment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_attachment(resp) + return resp + + class _DeleteFile( + _BaseArtifactRegistryRestTransport._BaseDeleteFile, ArtifactRegistryRestStub + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.DeleteFile") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: file.DeleteFileRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete file method over HTTP. + + Args: + request (~.file.DeleteFileRequest): + The request object. The request to delete a file. + 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: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_file(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._DeleteFile._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_file(resp) + return resp + class _DeletePackage( _BaseArtifactRegistryRestTransport._BaseDeletePackage, ArtifactRegistryRestStub ): @@ -1704,7 +2455,99 @@ def __call__( ) # Send the request - response = ArtifactRegistryRestTransport._DeletePackage._get_response( + response = ArtifactRegistryRestTransport._DeletePackage._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_package(resp) + return resp + + class _DeleteRepository( + _BaseArtifactRegistryRestTransport._BaseDeleteRepository, + ArtifactRegistryRestStub, + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.DeleteRepository") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: repository.DeleteRepositoryRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete repository method over HTTP. + + Args: + request (~.repository.DeleteRepositoryRequest): + The request object. The request to delete a repository. + 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: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_http_options() + ) + request, metadata = self._interceptor.pre_delete_repository( + request, metadata + ) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._DeleteRepository._get_response( self._host, metadata, query_params, @@ -1721,15 +2564,14 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_package(resp) + resp = self._interceptor.post_delete_repository(resp) return resp - class _DeleteRepository( - _BaseArtifactRegistryRestTransport._BaseDeleteRepository, - ArtifactRegistryRestStub, + class _DeleteRule( + _BaseArtifactRegistryRestTransport._BaseDeleteRule, ArtifactRegistryRestStub ): def __hash__(self): - return hash("ArtifactRegistryRestTransport.DeleteRepository") + return hash("ArtifactRegistryRestTransport.DeleteRule") @staticmethod def _get_response( @@ -1755,48 +2597,39 @@ def _get_response( def __call__( self, - request: repository.DeleteRepositoryRequest, + request: rule.DeleteRuleRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> operations_pb2.Operation: - r"""Call the delete repository method over HTTP. + ): + r"""Call the delete rule method over HTTP. Args: - request (~.repository.DeleteRepositoryRequest): - The request object. The request to delete a repository. + request (~.rule.DeleteRuleRequest): + The request object. The request to delete a rule. 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: - This resource represents a - long-running operation that is the - result of a network API call. - """ http_options = ( - _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_http_options() - ) - request, metadata = self._interceptor.pre_delete_repository( - request, metadata + _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_http_options() ) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_transcoded_request( + request, metadata = self._interceptor.pre_delete_rule(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_transcoded_request( http_options, request ) # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_query_params_json( + query_params = _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_query_params_json( transcoded_request ) # Send the request - response = ArtifactRegistryRestTransport._DeleteRepository._get_response( + response = ArtifactRegistryRestTransport._DeleteRule._get_response( self._host, metadata, query_params, @@ -1810,12 +2643,6 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_repository(resp) - return resp - class _DeleteTag( _BaseArtifactRegistryRestTransport._BaseDeleteTag, ArtifactRegistryRestStub ): @@ -1981,6 +2808,100 @@ def __call__( resp = self._interceptor.post_delete_version(resp) return resp + class _GetAttachment( + _BaseArtifactRegistryRestTransport._BaseGetAttachment, ArtifactRegistryRestStub + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.GetAttachment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: attachment.GetAttachmentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> attachment.Attachment: + r"""Call the get attachment method over HTTP. + + Args: + request (~.attachment.GetAttachmentRequest): + The request object. The request to retrieve an + attachment. + 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: + ~.attachment.Attachment: + An Attachment refers to additional + metadata that can be attached to + artifacts in Artifact Registry. An + attachment consists of one or more + files. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_http_options() + ) + request, metadata = self._interceptor.pre_get_attachment(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._GetAttachment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = attachment.Attachment() + pb_resp = attachment.Attachment.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attachment(resp) + return resp + class _GetDockerImage( _BaseArtifactRegistryRestTransport._BaseGetDockerImage, ArtifactRegistryRestStub ): @@ -2887,6 +3808,104 @@ def __call__( resp = self._interceptor.post_get_repository(resp) return resp + class _GetRule( + _BaseArtifactRegistryRestTransport._BaseGetRule, ArtifactRegistryRestStub + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.GetRule") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: rule.GetRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> rule.Rule: + r"""Call the get rule method over HTTP. + + Args: + request (~.rule.GetRuleRequest): + The request object. The request to retrieve a rule. + 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: + ~.rule.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseGetRule._get_http_options() + ) + request, metadata = self._interceptor.pre_get_rule(request, metadata) + transcoded_request = ( + _BaseArtifactRegistryRestTransport._BaseGetRule._get_transcoded_request( + http_options, request + ) + ) + + # Jsonify the query params + query_params = ( + _BaseArtifactRegistryRestTransport._BaseGetRule._get_query_params_json( + transcoded_request + ) + ) + + # Send the request + response = ArtifactRegistryRestTransport._GetRule._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = rule.Rule() + pb_resp = rule.Rule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_rule(resp) + return resp + class _GetTag( _BaseArtifactRegistryRestTransport._BaseGetTag, ArtifactRegistryRestStub ): @@ -3360,9 +4379,102 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_import_yum_artifacts(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_import_yum_artifacts(resp) + return resp + + class _ListAttachments( + _BaseArtifactRegistryRestTransport._BaseListAttachments, + ArtifactRegistryRestStub, + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.ListAttachments") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: attachment.ListAttachmentsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> attachment.ListAttachmentsResponse: + r"""Call the list attachments method over HTTP. + + Args: + request (~.attachment.ListAttachmentsRequest): + The request object. The request to list attachments. + 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: + ~.attachment.ListAttachmentsResponse: + The response from listing + attachments. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseListAttachments._get_http_options() + ) + request, metadata = self._interceptor.pre_list_attachments( + request, metadata + ) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseListAttachments._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseListAttachments._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._ListAttachments._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = attachment.ListAttachmentsResponse() + pb_resp = attachment.ListAttachmentsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_attachments(resp) return resp class _ListDockerImages( @@ -4006,6 +5118,94 @@ def __call__( resp = self._interceptor.post_list_repositories(resp) return resp + class _ListRules( + _BaseArtifactRegistryRestTransport._BaseListRules, ArtifactRegistryRestStub + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.ListRules") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: rule.ListRulesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> rule.ListRulesResponse: + r"""Call the list rules method over HTTP. + + Args: + request (~.rule.ListRulesRequest): + The request object. The request to list rules. + 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: + ~.rule.ListRulesResponse: + The response from listing rules. + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseListRules._get_http_options() + ) + request, metadata = self._interceptor.pre_list_rules(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseListRules._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseListRules._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._ListRules._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = rule.ListRulesResponse() + pb_resp = rule.ListRulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_rules(resp) + return resp + class _ListTags( _BaseArtifactRegistryRestTransport._BaseListTags, ArtifactRegistryRestStub ): @@ -4313,24 +5513,218 @@ def __call__( """ http_options = ( - _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_http_options() + _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_http_options() + ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_transcoded_request( + http_options, request + ) + + body = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._SetIamPolicy._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = policy_pb2.Policy() + pb_resp = resp + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + return resp + + class _TestIamPermissions( + _BaseArtifactRegistryRestTransport._BaseTestIamPermissions, + ArtifactRegistryRestStub, + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.TestIamPermissions") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: iam_policy_pb2.TestIamPermissionsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> iam_policy_pb2.TestIamPermissionsResponse: + r"""Call the test iam permissions method over HTTP. + + Args: + request (~.iam_policy_pb2.TestIamPermissionsRequest): + The request object. Request message for ``TestIamPermissions`` method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.iam_policy_pb2.TestIamPermissionsResponse: + Response message for ``TestIamPermissions`` method. + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_http_options() + ) + request, metadata = self._interceptor.pre_test_iam_permissions( + request, metadata + ) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_transcoded_request( + http_options, request + ) + + body = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._TestIamPermissions._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = iam_policy_pb2.TestIamPermissionsResponse() + pb_resp = resp + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + return resp + + class _UpdateFile( + _BaseArtifactRegistryRestTransport._BaseUpdateFile, ArtifactRegistryRestStub + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.UpdateFile") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: gda_file.UpdateFileRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gda_file.File: + r"""Call the update file method over HTTP. + + Args: + request (~.gda_file.UpdateFileRequest): + The request object. The request to update a file. + 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: + ~.gda_file.File: + Files store content that is + potentially associated with Packages or + Versions. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_http_options() ) - request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_transcoded_request( + request, metadata = self._interceptor.pre_update_file(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_transcoded_request( http_options, request ) - body = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_request_body_json( + body = _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_query_params_json( + query_params = _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_query_params_json( transcoded_request ) # Send the request - response = ArtifactRegistryRestTransport._SetIamPolicy._get_response( + response = ArtifactRegistryRestTransport._UpdateFile._get_response( self._host, metadata, query_params, @@ -4346,19 +5740,18 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = policy_pb2.Policy() - pb_resp = resp + resp = gda_file.File() + pb_resp = gda_file.File.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_set_iam_policy(resp) + resp = self._interceptor.post_update_file(resp) return resp - class _TestIamPermissions( - _BaseArtifactRegistryRestTransport._BaseTestIamPermissions, - ArtifactRegistryRestStub, + class _UpdatePackage( + _BaseArtifactRegistryRestTransport._BaseUpdatePackage, ArtifactRegistryRestStub ): def __hash__(self): - return hash("ArtifactRegistryRestTransport.TestIamPermissions") + return hash("ArtifactRegistryRestTransport.UpdatePackage") @staticmethod def _get_response( @@ -4385,17 +5778,17 @@ def _get_response( def __call__( self, - request: iam_policy_pb2.TestIamPermissionsRequest, + request: gda_package.UpdatePackageRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Call the test iam permissions method over HTTP. + ) -> gda_package.Package: + r"""Call the update package method over HTTP. Args: - request (~.iam_policy_pb2.TestIamPermissionsRequest): - The request object. Request message for ``TestIamPermissions`` method. + request (~.gda_package.UpdatePackageRequest): + The request object. The request to update a package. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -4403,31 +5796,31 @@ def __call__( sent along with the request as metadata. Returns: - ~.iam_policy_pb2.TestIamPermissionsResponse: - Response message for ``TestIamPermissions`` method. + ~.gda_package.Package: + Packages are named collections of + versions. + """ http_options = ( - _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_http_options() + _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_http_options() ) - request, metadata = self._interceptor.pre_test_iam_permissions( - request, metadata - ) - transcoded_request = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_transcoded_request( + request, metadata = self._interceptor.pre_update_package(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_transcoded_request( http_options, request ) - body = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_request_body_json( + body = _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_query_params_json( + query_params = _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_query_params_json( transcoded_request ) # Send the request - response = ArtifactRegistryRestTransport._TestIamPermissions._get_response( + response = ArtifactRegistryRestTransport._UpdatePackage._get_response( self._host, metadata, query_params, @@ -4443,11 +5836,11 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = iam_policy_pb2.TestIamPermissionsResponse() - pb_resp = resp + resp = gda_package.Package() + pb_resp = gda_package.Package.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_test_iam_permissions(resp) + resp = self._interceptor.post_update_package(resp) return resp class _UpdateProjectSettings( @@ -4650,6 +6043,106 @@ def __call__( resp = self._interceptor.post_update_repository(resp) return resp + class _UpdateRule( + _BaseArtifactRegistryRestTransport._BaseUpdateRule, ArtifactRegistryRestStub + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.UpdateRule") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: gda_rule.UpdateRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gda_rule.Rule: + r"""Call the update rule method over HTTP. + + Args: + request (~.gda_rule.UpdateRuleRequest): + The request object. The request to update a rule. + 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: + ~.gda_rule.Rule: + A rule defines the deny or allow + action of the operation it applies to + and the conditions required for the rule + to apply. You can set one rule for an + entire repository and one rule for each + package within. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_http_options() + ) + request, metadata = self._interceptor.pre_update_rule(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_transcoded_request( + http_options, request + ) + + body = _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._UpdateRule._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = gda_rule.Rule() + pb_resp = gda_rule.Rule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_rule(resp) + return resp + class _UpdateTag( _BaseArtifactRegistryRestTransport._BaseUpdateTag, ArtifactRegistryRestStub ): @@ -4748,6 +6241,105 @@ def __call__( resp = self._interceptor.post_update_tag(resp) return resp + class _UpdateVersion( + _BaseArtifactRegistryRestTransport._BaseUpdateVersion, ArtifactRegistryRestStub + ): + def __hash__(self): + return hash("ArtifactRegistryRestTransport.UpdateVersion") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: gda_version.UpdateVersionRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gda_version.Version: + r"""Call the update version method over HTTP. + + Args: + request (~.gda_version.UpdateVersionRequest): + The request object. The request to update a version. + 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: + ~.gda_version.Version: + The body of a version resource. A + version resource represents a collection + of components, such as files and other + data. This may correspond to a version + in many package management schemes. + + """ + + http_options = ( + _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_http_options() + ) + request, metadata = self._interceptor.pre_update_version(request, metadata) + transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_transcoded_request( + http_options, request + ) + + body = _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_query_params_json( + transcoded_request + ) + + # Send the request + response = ArtifactRegistryRestTransport._UpdateVersion._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = gda_version.Version() + pb_resp = gda_version.Version.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_version(resp) + return resp + class _UpdateVPCSCConfig( _BaseArtifactRegistryRestTransport._BaseUpdateVPCSCConfig, ArtifactRegistryRestStub, @@ -4855,6 +6447,14 @@ def batch_delete_versions( # In C++ this would require a dynamic_cast return self._BatchDeleteVersions(self._session, self._host, self._interceptor) # type: ignore + @property + def create_attachment( + self, + ) -> Callable[[gda_attachment.CreateAttachmentRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateAttachment(self._session, self._host, self._interceptor) # type: ignore + @property def create_repository( self, @@ -4863,12 +6463,34 @@ def create_repository( # In C++ this would require a dynamic_cast return self._CreateRepository(self._session, self._host, self._interceptor) # type: ignore + @property + def create_rule(self) -> Callable[[gda_rule.CreateRuleRequest], gda_rule.Rule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateRule(self._session, self._host, self._interceptor) # type: ignore + @property def create_tag(self) -> Callable[[gda_tag.CreateTagRequest], gda_tag.Tag]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast return self._CreateTag(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_attachment( + self, + ) -> Callable[[attachment.DeleteAttachmentRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteAttachment(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_file( + self, + ) -> Callable[[file.DeleteFileRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteFile(self._session, self._host, self._interceptor) # type: ignore + @property def delete_package( self, @@ -4885,6 +6507,12 @@ def delete_repository( # In C++ this would require a dynamic_cast return self._DeleteRepository(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_rule(self) -> Callable[[rule.DeleteRuleRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteRule(self._session, self._host, self._interceptor) # type: ignore + @property def delete_tag(self) -> Callable[[tag.DeleteTagRequest], empty_pb2.Empty]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. @@ -4899,6 +6527,14 @@ def delete_version( # In C++ this would require a dynamic_cast return self._DeleteVersion(self._session, self._host, self._interceptor) # type: ignore + @property + def get_attachment( + self, + ) -> Callable[[attachment.GetAttachmentRequest], attachment.Attachment]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetAttachment(self._session, self._host, self._interceptor) # type: ignore + @property def get_docker_image( self, @@ -4967,6 +6603,12 @@ def get_repository( # In C++ this would require a dynamic_cast return self._GetRepository(self._session, self._host, self._interceptor) # type: ignore + @property + def get_rule(self) -> Callable[[rule.GetRuleRequest], rule.Rule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetRule(self._session, self._host, self._interceptor) # type: ignore + @property def get_tag(self) -> Callable[[tag.GetTagRequest], tag.Tag]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. @@ -5003,6 +6645,16 @@ def import_yum_artifacts( # In C++ this would require a dynamic_cast return self._ImportYumArtifacts(self._session, self._host, self._interceptor) # type: ignore + @property + def list_attachments( + self, + ) -> Callable[ + [attachment.ListAttachmentsRequest], attachment.ListAttachmentsResponse + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListAttachments(self._session, self._host, self._interceptor) # type: ignore + @property def list_docker_images( self, @@ -5065,6 +6717,12 @@ def list_repositories( # In C++ this would require a dynamic_cast return self._ListRepositories(self._session, self._host, self._interceptor) # type: ignore + @property + def list_rules(self) -> Callable[[rule.ListRulesRequest], rule.ListRulesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListRules(self._session, self._host, self._interceptor) # type: ignore + @property def list_tags(self) -> Callable[[tag.ListTagsRequest], tag.ListTagsResponse]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. @@ -5098,6 +6756,20 @@ def test_iam_permissions( # In C++ this would require a dynamic_cast return self._TestIamPermissions(self._session, self._host, self._interceptor) # type: ignore + @property + def update_file(self) -> Callable[[gda_file.UpdateFileRequest], gda_file.File]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateFile(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_package( + self, + ) -> Callable[[gda_package.UpdatePackageRequest], gda_package.Package]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdatePackage(self._session, self._host, self._interceptor) # type: ignore + @property def update_project_settings( self, @@ -5114,12 +6786,26 @@ def update_repository( # In C++ this would require a dynamic_cast return self._UpdateRepository(self._session, self._host, self._interceptor) # type: ignore + @property + def update_rule(self) -> Callable[[gda_rule.UpdateRuleRequest], gda_rule.Rule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateRule(self._session, self._host, self._interceptor) # type: ignore + @property def update_tag(self) -> Callable[[gda_tag.UpdateTagRequest], gda_tag.Tag]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast return self._UpdateTag(self._session, self._host, self._interceptor) # type: ignore + @property + def update_version( + self, + ) -> Callable[[gda_version.UpdateVersionRequest], gda_version.Version]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateVersion(self._session, self._host, self._interceptor) # type: ignore + @property def update_vpcsc_config( self, diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest_base.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest_base.py index 8361b950576f..d36109560ccc 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest_base.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest_base.py @@ -25,14 +25,23 @@ from google.protobuf import empty_pb2 # type: ignore from google.protobuf import json_format -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 apt_artifact, artifact +from google.cloud.artifactregistry_v1.types import attachment +from google.cloud.artifactregistry_v1.types import attachment as gda_attachment +from google.cloud.artifactregistry_v1.types import file +from google.cloud.artifactregistry_v1.types import file as gda_file +from google.cloud.artifactregistry_v1.types import package +from google.cloud.artifactregistry_v1.types import package as gda_package 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 rule +from google.cloud.artifactregistry_v1.types import rule as gda_rule 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 +from google.cloud.artifactregistry_v1.types import version as gda_version from google.cloud.artifactregistry_v1.types import vpcsc_config from google.cloud.artifactregistry_v1.types import yum_artifact @@ -158,6 +167,65 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseCreateAttachment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "attachmentId": "", + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/attachments", + "body": "attachment", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gda_attachment.CreateAttachmentRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseCreateRepository: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -217,6 +285,63 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseCreateRule: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/rules", + "body": "rule", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gda_rule.CreateRuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseCreateRule._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseCreateTag: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -259,6 +384,100 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseDeleteAttachment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/attachments/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = attachment.DeleteAttachmentRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteFile: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/files/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = file.DeleteFileRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseDeletePackage: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -353,6 +572,53 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseDeleteRule: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/rules/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = rule.DeleteRuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseDeleteTag: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -417,6 +683,53 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseGetAttachment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/attachments/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = attachment.GetAttachmentRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseGetDockerImage: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -840,6 +1153,53 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseGetRule: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/rules/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = rule.GetRuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseGetRule._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseGetTag: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -968,7 +1328,49 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = apt_artifact.ImportAptArtifactsRequest.pb(request) + pb_request = apt_artifact.ImportAptArtifactsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseImportYumArtifacts: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/yumArtifacts:import", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = yum_artifact.ImportYumArtifactsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -993,36 +1395,36 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseImportYumArtifacts: + class _BaseListAttachments: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + @staticmethod def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/yumArtifacts:import", - "body": "*", + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/attachments", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = yum_artifact.ImportYumArtifactsRequest.pb(request) + pb_request = attachment.ListAttachmentsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -1031,6 +1433,11 @@ def _get_query_params_json(transcoded_request): use_integers_for_enums=True, ) ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseListAttachments._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1364,6 +1771,53 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseListRules: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/rules", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = rule.ListRulesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseListRules._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseListTags: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1542,6 +1996,107 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseUpdateFile: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask": {}, + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{file.name=projects/*/locations/*/repositories/*/files/*}", + "body": "file", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gda_file.UpdateFileRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdatePackage: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{package.name=projects/*/locations/*/repositories/*/packages/*}", + "body": "package", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gda_package.UpdatePackageRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseUpdateProjectSettings: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1626,6 +2181,48 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseUpdateRule: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{rule.name=projects/*/locations/*/repositories/*/rules/*}", + "body": "rule", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gda_rule.UpdateRuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseUpdateTag: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -1668,6 +2265,63 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params + class _BaseUpdateVersion: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{version.name=projects/*/locations/*/repositories/*/packages/*/versions/*}", + "body": "version", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = gda_version.UpdateVersionRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseUpdateVPCSCConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/__init__.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/__init__.py index 03d8f5baa554..9d71c93dac06 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/__init__.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/__init__.py @@ -39,13 +39,31 @@ NpmPackage, PythonPackage, ) -from .file import File, GetFileRequest, Hash, ListFilesRequest, ListFilesResponse +from .attachment import ( + Attachment, + CreateAttachmentRequest, + DeleteAttachmentRequest, + GetAttachmentRequest, + ListAttachmentsRequest, + ListAttachmentsResponse, +) +from .file import ( + DeleteFileRequest, + File, + GetFileRequest, + Hash, + ListFilesRequest, + ListFilesResponse, + UpdateFileRequest, +) +from .generic import GenericArtifact from .package import ( DeletePackageRequest, GetPackageRequest, ListPackagesRequest, ListPackagesResponse, Package, + UpdatePackageRequest, ) from .repository import ( CleanupPolicy, @@ -62,6 +80,15 @@ UpstreamPolicy, VirtualRepositoryConfig, ) +from .rule import ( + CreateRuleRequest, + DeleteRuleRequest, + GetRuleRequest, + ListRulesRequest, + ListRulesResponse, + Rule, + UpdateRuleRequest, +) from .service import OperationMetadata from .settings import ( GetProjectSettingsRequest, @@ -84,6 +111,7 @@ GetVersionRequest, ListVersionsRequest, ListVersionsResponse, + UpdateVersionRequest, Version, VersionView, ) @@ -120,16 +148,26 @@ "MavenArtifact", "NpmPackage", "PythonPackage", + "Attachment", + "CreateAttachmentRequest", + "DeleteAttachmentRequest", + "GetAttachmentRequest", + "ListAttachmentsRequest", + "ListAttachmentsResponse", + "DeleteFileRequest", "File", "GetFileRequest", "Hash", "ListFilesRequest", "ListFilesResponse", + "UpdateFileRequest", + "GenericArtifact", "DeletePackageRequest", "GetPackageRequest", "ListPackagesRequest", "ListPackagesResponse", "Package", + "UpdatePackageRequest", "CleanupPolicy", "CleanupPolicyCondition", "CleanupPolicyMostRecentVersions", @@ -143,6 +181,13 @@ "UpdateRepositoryRequest", "UpstreamPolicy", "VirtualRepositoryConfig", + "CreateRuleRequest", + "DeleteRuleRequest", + "GetRuleRequest", + "ListRulesRequest", + "ListRulesResponse", + "Rule", + "UpdateRuleRequest", "OperationMetadata", "GetProjectSettingsRequest", "ProjectSettings", @@ -160,6 +205,7 @@ "GetVersionRequest", "ListVersionsRequest", "ListVersionsResponse", + "UpdateVersionRequest", "Version", "VersionView", "GetVPCSCConfigRequest", diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/artifact.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/artifact.py index 5b1950637fab..40db288339c7 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/artifact.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/artifact.py @@ -143,6 +143,7 @@ class ListDockerImagesRequest(proto.Message): whose docker images will be listed. page_size (int): The maximum number of artifacts to return. + Maximum page size is 1,000. page_token (str): The next_page_token value returned from a previous list request, if any. @@ -282,6 +283,7 @@ class ListMavenArtifactsRequest(proto.Message): whose maven artifacts will be listed. page_size (int): The maximum number of artifacts to return. + Maximum page size is 1,000. page_token (str): The next_page_token value returned from a previous list request, if any. @@ -402,6 +404,7 @@ class ListNpmPackagesRequest(proto.Message): whose npm packages will be listed. page_size (int): The maximum number of artifacts to return. + Maximum page size is 1,000. page_token (str): The next_page_token value returned from a previous list request, if any. @@ -526,6 +529,7 @@ class ListPythonPackagesRequest(proto.Message): whose python packages will be listed. page_size (int): The maximum number of artifacts to return. + Maximum page size is 1,000. page_token (str): The next_page_token value returned from a previous list request, if any. diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/attachment.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/attachment.py similarity index 94% rename from owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/attachment.py rename to packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/attachment.py index fb60a788ab80..027d5f1b59a7 100644 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/attachment.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/attachment.py @@ -17,20 +17,18 @@ from typing import MutableMapping, MutableSequence -import proto # type: ignore - from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', + package="google.devtools.artifactregistry.v1", manifest={ - 'Attachment', - 'ListAttachmentsRequest', - 'ListAttachmentsResponse', - 'GetAttachmentRequest', - 'CreateAttachmentRequest', - 'DeleteAttachmentRequest', + "Attachment", + "ListAttachmentsRequest", + "ListAttachmentsResponse", + "GetAttachmentRequest", + "CreateAttachmentRequest", + "DeleteAttachmentRequest", }, ) @@ -175,10 +173,10 @@ class ListAttachmentsResponse(proto.Message): def raw_page(self): return self - attachments: MutableSequence['Attachment'] = proto.RepeatedField( + attachments: MutableSequence["Attachment"] = proto.RepeatedField( proto.MESSAGE, number=1, - message='Attachment', + message="Attachment", ) next_page_token: str = proto.Field( proto.STRING, @@ -223,10 +221,10 @@ class CreateAttachmentRequest(proto.Message): proto.STRING, number=2, ) - attachment: 'Attachment' = proto.Field( + attachment: "Attachment" = proto.Field( proto.MESSAGE, number=3, - message='Attachment', + message="Attachment", ) diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/file.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/file.py index 25cdafe65255..684c98fe873e 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/file.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/file.py @@ -17,6 +17,7 @@ from typing import MutableMapping, MutableSequence +from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore @@ -28,6 +29,8 @@ "ListFilesRequest", "ListFilesResponse", "GetFileRequest", + "DeleteFileRequest", + "UpdateFileRequest", }, ) @@ -75,10 +78,8 @@ class File(proto.Message): Attributes: name (str): The name of the file, for example: - - "projects/p1/locations/us-central1/repositories/repo1/files/a%2Fb%2Fc.txt". - If the file ID part contains slashes, they are - escaped. + ``projects/p1/locations/us-central1/repositories/repo1/files/a%2Fb%2Fc.txt``. + If the file ID part contains slashes, they are escaped. size_bytes (int): The size of the File in bytes. hashes (MutableSequence[google.cloud.artifactregistry_v1.types.Hash]): @@ -96,6 +97,8 @@ class File(proto.Message): Output only. The time when the last attempt to refresh the file's data was made. Only set when the repository is remote. + annotations (MutableMapping[str, str]): + Optional. Client specified annotations. """ name: str = proto.Field( @@ -130,6 +133,11 @@ class File(proto.Message): number=8, message=timestamp_pb2.Timestamp, ) + annotations: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=9, + ) class ListFilesRequest(proto.Message): @@ -147,16 +155,59 @@ class ListFilesRequest(proto.Message): - ``name`` - ``owner`` + - ``annotations`` + + Examples of using a filter: + + To filter the results of your request to files with the name + ``my_file.txt`` in project ``my-project`` in the + ``us-central`` region, in repository ``my-repo``, append the + following filter expression to your request: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/files/my-file.txt"`` + + You can also use wildcards to match any number of characters + before or after the value: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/files/my-*"`` + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/files/*file.txt"`` + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/files/*file*"`` + + To filter the results of your request to files owned by the + version ``1.0`` in package ``pkg1``, append the following + filter expression to your request: + + - ``owner="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/1.0"`` - An example of using a filter: + To filter the results of your request to files with the + annotation key-value pair [``external_link``: + ``external_link_value``], append the following filter + expression to your request: - - ``name="projects/p1/locations/us-central1/repositories/repo1/files/a/b/*"`` - --> Files with an ID starting with "a/b/". - - ``owner="projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/1.0"`` - --> Files owned by the version ``1.0`` in package - ``pkg1``. + - ``"annotations.external_link:external_link_value"`` + + To filter just for a specific annotation key + ``external_link``, append the following filter expression to + your request: + + - ``"annotations.external_link"`` + + If the annotation key or value contains special characters, + you can escape them by surrounding the value with backticks. + For example, to filter the results of your request to files + with the annotation key-value pair + [``external.link``:``https://example.com/my-file``], append + the following filter expression to your request: + + - :literal:`"annotations.`external.link`:`https://example.com/my-file`"` + + You can also filter with annotations with a wildcard to + match any number of characters before or after the value: + + - :literal:`"annotations.*_link:`*example.com*`"` page_size (int): The maximum number of files to return. + Maximum page size is 1,000. page_token (str): The next_page_token value returned from a previous list request, if any. @@ -226,4 +277,43 @@ class GetFileRequest(proto.Message): ) +class DeleteFileRequest(proto.Message): + r"""The request to delete a file. + + Attributes: + name (str): + Required. The name of the file to delete. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateFileRequest(proto.Message): + r"""The request to update a file. + + Attributes: + file (google.cloud.artifactregistry_v1.types.File): + Required. The File that replaces the resource + on the server. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + file: "File" = proto.Field( + proto.MESSAGE, + number=1, + message="File", + ) + 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/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/generic.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/generic.py similarity index 96% rename from owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/generic.py rename to packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/generic.py index 56cd5a9d5c0b..f6a2134dcc6b 100644 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/generic.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/generic.py @@ -17,15 +17,13 @@ from typing import MutableMapping, MutableSequence -import proto # type: ignore - from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', + package="google.devtools.artifactregistry.v1", manifest={ - 'GenericArtifact', + "GenericArtifact", }, ) diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/package.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/package.py index fb57d551a255..0b2d1b2a11fa 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/package.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/package.py @@ -17,6 +17,7 @@ from typing import MutableMapping, MutableSequence +from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore @@ -28,6 +29,7 @@ "ListPackagesResponse", "GetPackageRequest", "DeletePackageRequest", + "UpdatePackageRequest", }, ) @@ -49,6 +51,8 @@ class Package(proto.Message): The time when the package was last updated. This includes publishing a new version of the package. + annotations (MutableMapping[str, str]): + Optional. Client specified annotations. """ name: str = proto.Field( @@ -69,6 +73,11 @@ class Package(proto.Message): number=6, message=timestamp_pb2.Timestamp, ) + annotations: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=7, + ) class ListPackagesRequest(proto.Message): @@ -84,6 +93,58 @@ class ListPackagesRequest(proto.Message): page_token (str): The next_page_token value returned from a previous list request, if any. + filter (str): + Optional. An expression for filtering the results of the + request. Filter rules are case insensitive. The fields + eligible for filtering are: + + - ``name`` + - ``annotations`` + + Examples of using a filter: + + To filter the results of your request to packages with the + name ``my-package`` in project ``my-project`` in the + ``us-central`` region, in repository ``my-repo``, append the + following filter expression to your request: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package"`` + + You can also use wildcards to match any number of characters + before or after the value: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-*"`` + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/*package"`` + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/*pack*"`` + + To filter the results of your request to packages with the + annotation key-value pair [``external_link``: + ``external_link_value``], append the following filter + expression to your request": + + - ``"annotations.external_link:external_link_value"`` + + To filter the results just for a specific annotation key + ``external_link``, append the following filter expression to + your request: + + - ``"annotations.external_link"`` + + If the annotation key or value contains special characters, + you can escape them by surrounding the value with backticks. + For example, to filter the results of your request to + packages with the annotation key-value pair + [``external.link``:``https://example.com/my-package``], + append the following filter expression to your request: + + - :literal:`"annotations.`external.link`:`https://example.com/my-package`"` + + You can also filter with annotations with a wildcard to + match any number of characters before or after the value: + + - :literal:`"annotations.*_link:`*example.com*`"` + order_by (str): + Optional. The field to order the results by. """ parent: str = proto.Field( @@ -98,6 +159,14 @@ class ListPackagesRequest(proto.Message): proto.STRING, number=3, ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) class ListPackagesResponse(proto.Message): @@ -156,4 +225,29 @@ class DeletePackageRequest(proto.Message): ) +class UpdatePackageRequest(proto.Message): + r"""The request to update a package. + + Attributes: + package (google.cloud.artifactregistry_v1.types.Package): + The package that replaces the resource on the + server. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + package: "Package" = proto.Field( + proto.MESSAGE, + number=1, + message="Package", + ) + 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/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/repository.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/repository.py index 7dad052e30d8..74e18ace3e93 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/repository.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/repository.py @@ -304,12 +304,22 @@ class RemoteRepositoryConfig(proto.Message): Specific settings for a Yum remote repository. + This field is a member of `oneof`_ ``remote_source``. + common_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.CommonRemoteRepository): + Common remote repository settings. + Used as the remote repository upstream URL. + This field is a member of `oneof`_ ``remote_source``. description (str): The description of the remote source. upstream_credentials (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.UpstreamCredentials): Optional. The credentials used to access the remote repository. + disable_upstream_validation (bool): + Input only. A create/update remote repo + option to avoid making a HEAD/GET request to + validate a remote repo and any supplied upstream + credentials. """ class UpstreamCredentials(proto.Message): @@ -356,6 +366,11 @@ class UsernamePasswordCredentials(proto.Message): class DockerRepository(proto.Message): r"""Configuration for a Docker remote repository. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: @@ -363,6 +378,10 @@ class DockerRepository(proto.Message): One of the publicly available Docker repositories supported by Artifact Registry. + This field is a member of `oneof`_ ``upstream``. + custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.DockerRepository.CustomRepository): + Customer-specified remote repository. + This field is a member of `oneof`_ ``upstream``. """ @@ -379,16 +398,42 @@ class PublicRepository(proto.Enum): PUBLIC_REPOSITORY_UNSPECIFIED = 0 DOCKER_HUB = 1 + class CustomRepository(proto.Message): + r"""Customer-specified publicly available remote repository. + + Attributes: + uri (str): + An http/https uri reference to the custom + remote repository, for ex: + "https://registry-1.docker.io". + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + public_repository: "RemoteRepositoryConfig.DockerRepository.PublicRepository" = proto.Field( proto.ENUM, number=1, oneof="upstream", enum="RemoteRepositoryConfig.DockerRepository.PublicRepository", ) + custom_repository: "RemoteRepositoryConfig.DockerRepository.CustomRepository" = proto.Field( + proto.MESSAGE, + number=3, + oneof="upstream", + message="RemoteRepositoryConfig.DockerRepository.CustomRepository", + ) class MavenRepository(proto.Message): r"""Configuration for a Maven remote repository. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: @@ -396,6 +441,10 @@ class MavenRepository(proto.Message): One of the publicly available Maven repositories supported by Artifact Registry. + This field is a member of `oneof`_ ``upstream``. + custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.MavenRepository.CustomRepository): + Customer-specified remote repository. + This field is a member of `oneof`_ ``upstream``. """ @@ -412,6 +461,21 @@ class PublicRepository(proto.Enum): PUBLIC_REPOSITORY_UNSPECIFIED = 0 MAVEN_CENTRAL = 1 + class CustomRepository(proto.Message): + r"""Customer-specified publicly available remote repository. + + Attributes: + uri (str): + An http/https uri reference to the upstream + remote repository, for ex: + "https://my.maven.registry/". + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + public_repository: "RemoteRepositoryConfig.MavenRepository.PublicRepository" = ( proto.Field( proto.ENUM, @@ -420,10 +484,23 @@ class PublicRepository(proto.Enum): enum="RemoteRepositoryConfig.MavenRepository.PublicRepository", ) ) + custom_repository: "RemoteRepositoryConfig.MavenRepository.CustomRepository" = ( + proto.Field( + proto.MESSAGE, + number=3, + oneof="upstream", + message="RemoteRepositoryConfig.MavenRepository.CustomRepository", + ) + ) class NpmRepository(proto.Message): r"""Configuration for a Npm remote repository. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: @@ -431,6 +508,10 @@ class NpmRepository(proto.Message): One of the publicly available Npm repositories supported by Artifact Registry. + This field is a member of `oneof`_ ``upstream``. + custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.NpmRepository.CustomRepository): + Customer-specified remote repository. + This field is a member of `oneof`_ ``upstream``. """ @@ -447,6 +528,21 @@ class PublicRepository(proto.Enum): PUBLIC_REPOSITORY_UNSPECIFIED = 0 NPMJS = 1 + class CustomRepository(proto.Message): + r"""Customer-specified publicly available remote repository. + + Attributes: + uri (str): + An http/https uri reference to the upstream + remote repository, for ex: + "https://my.npm.registry/". + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + public_repository: "RemoteRepositoryConfig.NpmRepository.PublicRepository" = ( proto.Field( proto.ENUM, @@ -455,10 +551,23 @@ class PublicRepository(proto.Enum): enum="RemoteRepositoryConfig.NpmRepository.PublicRepository", ) ) + custom_repository: "RemoteRepositoryConfig.NpmRepository.CustomRepository" = ( + proto.Field( + proto.MESSAGE, + number=3, + oneof="upstream", + message="RemoteRepositoryConfig.NpmRepository.CustomRepository", + ) + ) class PythonRepository(proto.Message): r"""Configuration for a Python remote repository. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: @@ -466,6 +575,10 @@ class PythonRepository(proto.Message): One of the publicly available Python repositories supported by Artifact Registry. + This field is a member of `oneof`_ ``upstream``. + custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.PythonRepository.CustomRepository): + Customer-specified remote repository. + This field is a member of `oneof`_ ``upstream``. """ @@ -482,16 +595,42 @@ class PublicRepository(proto.Enum): PUBLIC_REPOSITORY_UNSPECIFIED = 0 PYPI = 1 + class CustomRepository(proto.Message): + r"""Customer-specified publicly available remote repository. + + Attributes: + uri (str): + An http/https uri reference to the upstream + remote repository, for ex: + "https://my.python.registry/". + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + public_repository: "RemoteRepositoryConfig.PythonRepository.PublicRepository" = proto.Field( proto.ENUM, number=1, oneof="upstream", enum="RemoteRepositoryConfig.PythonRepository.PublicRepository", ) + custom_repository: "RemoteRepositoryConfig.PythonRepository.CustomRepository" = proto.Field( + proto.MESSAGE, + number=3, + oneof="upstream", + message="RemoteRepositoryConfig.PythonRepository.CustomRepository", + ) class AptRepository(proto.Message): r"""Configuration for an Apt remote repository. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: @@ -499,6 +638,10 @@ class AptRepository(proto.Message): One of the publicly available Apt repositories supported by Artifact Registry. + This field is a member of `oneof`_ ``upstream``. + custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.AptRepository.CustomRepository): + Customer-specified remote repository. + This field is a member of `oneof`_ ``upstream``. """ @@ -525,10 +668,13 @@ class RepositoryBase(proto.Enum): Debian. UBUNTU (2): Ubuntu LTS/Pro. + DEBIAN_SNAPSHOT (3): + Archived Debian. """ REPOSITORY_BASE_UNSPECIFIED = 0 DEBIAN = 1 UBUNTU = 2 + DEBIAN_SNAPSHOT = 3 repository_base: "RemoteRepositoryConfig.AptRepository.PublicRepository.RepositoryBase" = proto.Field( proto.ENUM, @@ -540,6 +686,21 @@ class RepositoryBase(proto.Enum): number=2, ) + class CustomRepository(proto.Message): + r"""Customer-specified publicly available remote repository. + + Attributes: + uri (str): + An http/https uri reference to the upstream + remote repository, for ex: + "https://my.apt.registry/". + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + public_repository: "RemoteRepositoryConfig.AptRepository.PublicRepository" = ( proto.Field( proto.MESSAGE, @@ -548,10 +709,23 @@ class RepositoryBase(proto.Enum): message="RemoteRepositoryConfig.AptRepository.PublicRepository", ) ) + custom_repository: "RemoteRepositoryConfig.AptRepository.CustomRepository" = ( + proto.Field( + proto.MESSAGE, + number=3, + oneof="upstream", + message="RemoteRepositoryConfig.AptRepository.CustomRepository", + ) + ) class YumRepository(proto.Message): r"""Configuration for a Yum remote repository. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: @@ -559,6 +733,10 @@ class YumRepository(proto.Message): One of the publicly available Yum repositories supported by Artifact Registry. + This field is a member of `oneof`_ ``upstream``. + custom_repository (google.cloud.artifactregistry_v1.types.RemoteRepositoryConfig.YumRepository.CustomRepository): + Customer-specified remote repository. + This field is a member of `oneof`_ ``upstream``. """ @@ -613,6 +791,21 @@ class RepositoryBase(proto.Enum): number=2, ) + class CustomRepository(proto.Message): + r"""Customer-specified publicly available remote repository. + + Attributes: + uri (str): + An http/https uri reference to the upstream + remote repository, for ex: + "https://my.yum.registry/". + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + public_repository: "RemoteRepositoryConfig.YumRepository.PublicRepository" = ( proto.Field( proto.MESSAGE, @@ -621,6 +814,28 @@ class RepositoryBase(proto.Enum): message="RemoteRepositoryConfig.YumRepository.PublicRepository", ) ) + custom_repository: "RemoteRepositoryConfig.YumRepository.CustomRepository" = ( + proto.Field( + proto.MESSAGE, + number=3, + oneof="upstream", + message="RemoteRepositoryConfig.YumRepository.CustomRepository", + ) + ) + + class CommonRemoteRepository(proto.Message): + r"""Common remote repository settings type. + + Attributes: + uri (str): + Required. A common public repository base for + remote repository. + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) docker_repository: DockerRepository = proto.Field( proto.MESSAGE, @@ -658,6 +873,12 @@ class RepositoryBase(proto.Enum): oneof="remote_source", message=YumRepository, ) + common_repository: CommonRemoteRepository = proto.Field( + proto.MESSAGE, + number=14, + oneof="remote_source", + message=CommonRemoteRepository, + ) description: str = proto.Field( proto.STRING, number=1, @@ -667,6 +888,10 @@ class RepositoryBase(proto.Enum): number=9, message=UpstreamCredentials, ) + disable_upstream_validation: bool = proto.Field( + proto.BOOL, + number=12, + ) class Repository(proto.Message): @@ -705,6 +930,8 @@ class Repository(proto.Message): name (str): The name of the repository, for example: ``projects/p1/locations/us-central1/repositories/repo1``. + For each location in a project, repository names must be + unique. format_ (google.cloud.artifactregistry_v1.types.Repository.Format): Optional. The format of packages that are stored in the repository. @@ -755,6 +982,16 @@ class Repository(proto.Message): Optional. If true, the cleanup pipeline is prevented from deleting versions in this repository. + vulnerability_scanning_config (google.cloud.artifactregistry_v1.types.Repository.VulnerabilityScanningConfig): + Optional. Config and state for vulnerability + scanning of resources within this Repository. + disallow_unspecified_mode (bool): + Optional. If this is true, an unspecified + repo type will be treated as error rather than + defaulting to standard. + satisfies_pzi (bool): + Output only. If set, the repository satisfies + physical zone isolation. """ class Format(proto.Enum): @@ -779,6 +1016,8 @@ class Format(proto.Enum): Kubeflow Pipelines package format. GO (10): Go package format. + GENERIC (11): + Generic package format. """ FORMAT_UNSPECIFIED = 0 DOCKER = 1 @@ -789,6 +1028,7 @@ class Format(proto.Enum): PYTHON = 8 KFP = 9 GO = 10 + GENERIC = 11 class Mode(proto.Enum): r"""The mode configures the repository to serve artifacts from @@ -872,6 +1112,91 @@ class DockerRepositoryConfig(proto.Message): number=1, ) + class VulnerabilityScanningConfig(proto.Message): + r"""Config on whether to perform vulnerability scanning for + resources in this repository, as well as output fields + describing current state. + + Attributes: + enablement_config (google.cloud.artifactregistry_v1.types.Repository.VulnerabilityScanningConfig.EnablementConfig): + Optional. Config for whether this repository + has vulnerability scanning disabled. + last_enable_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The last time this repository + config was enabled. + enablement_state (google.cloud.artifactregistry_v1.types.Repository.VulnerabilityScanningConfig.EnablementState): + Output only. State of feature enablement, + combining repository enablement config and API + enablement state. + enablement_state_reason (str): + Output only. Reason for the repository state. + """ + + class EnablementConfig(proto.Enum): + r"""Config for vulnerability scanning of resources in this + repository. + + Values: + ENABLEMENT_CONFIG_UNSPECIFIED (0): + Not set. This will be treated as INHERITED. + INHERITED (1): + Scanning is Enabled, but dependent on API + enablement. + DISABLED (2): + No automatic vulnerability scanning will be + performed for this repository. + """ + ENABLEMENT_CONFIG_UNSPECIFIED = 0 + INHERITED = 1 + DISABLED = 2 + + class EnablementState(proto.Enum): + r"""Describes the state of vulnerability scanning in this + repository, including both repository enablement and API + enablement. + + Values: + ENABLEMENT_STATE_UNSPECIFIED (0): + Enablement state is unclear. + SCANNING_UNSUPPORTED (1): + Repository does not support vulnerability + scanning. + SCANNING_DISABLED (2): + Vulnerability scanning is disabled for this + repository. + SCANNING_ACTIVE (3): + Vulnerability scanning is active for this + repository. + """ + ENABLEMENT_STATE_UNSPECIFIED = 0 + SCANNING_UNSUPPORTED = 1 + SCANNING_DISABLED = 2 + SCANNING_ACTIVE = 3 + + enablement_config: "Repository.VulnerabilityScanningConfig.EnablementConfig" = ( + proto.Field( + proto.ENUM, + number=1, + enum="Repository.VulnerabilityScanningConfig.EnablementConfig", + ) + ) + last_enable_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + enablement_state: "Repository.VulnerabilityScanningConfig.EnablementState" = ( + proto.Field( + proto.ENUM, + number=3, + enum="Repository.VulnerabilityScanningConfig.EnablementState", + ) + ) + enablement_state_reason: str = proto.Field( + proto.STRING, + number=4, + ) + maven_config: MavenRepositoryConfig = proto.Field( proto.MESSAGE, number=9, @@ -951,6 +1276,19 @@ class DockerRepositoryConfig(proto.Message): proto.BOOL, number=18, ) + vulnerability_scanning_config: VulnerabilityScanningConfig = proto.Field( + proto.MESSAGE, + number=19, + message=VulnerabilityScanningConfig, + ) + disallow_unspecified_mode: bool = proto.Field( + proto.BOOL, + number=21, + ) + satisfies_pzi: bool = proto.Field( + proto.BOOL, + number=22, + ) class ListRepositoriesRequest(proto.Message): @@ -966,6 +1304,30 @@ class ListRepositoriesRequest(proto.Message): page_token (str): The next_page_token value returned from a previous list request, if any. + filter (str): + Optional. An expression for filtering the results of the + request. Filter rules are case insensitive. The fields + eligible for filtering are: + + - ``name`` + + Examples of using a filter: + + To filter the results of your request to repositories with + the name ``my-repo`` in project ``my-project`` in the + ``us-central`` region, append the following filter + expression to your request: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo"`` + + You can also use wildcards to match any number of characters + before or after the value: + + - ``name="projects/my-project/locations/us-central1/repositories/my-*"`` + - ``name="projects/my-project/locations/us-central1/repositories/*repo"`` + - ``name="projects/my-project/locations/us-central1/repositories/*repo*"`` + order_by (str): + Optional. The field to order the results by. """ parent: str = proto.Field( @@ -980,6 +1342,14 @@ class ListRepositoriesRequest(proto.Message): proto.STRING, number=3, ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) class ListRepositoriesResponse(proto.Message): diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/rule.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/rule.py similarity index 93% rename from owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/rule.py rename to packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/rule.py index 7ebba40bd32a..c436dd859ea8 100644 --- a/owl-bot-staging/google-cloud-artifact-registry/v1/google/cloud/artifactregistry_v1/types/rule.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/rule.py @@ -17,22 +17,20 @@ from typing import MutableMapping, MutableSequence -import proto # type: ignore - from google.protobuf import field_mask_pb2 # type: ignore from google.type import expr_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( - package='google.devtools.artifactregistry.v1', + package="google.devtools.artifactregistry.v1", manifest={ - 'Rule', - 'ListRulesRequest', - 'ListRulesResponse', - 'GetRuleRequest', - 'CreateRuleRequest', - 'UpdateRuleRequest', - 'DeleteRuleRequest', + "Rule", + "ListRulesRequest", + "ListRulesResponse", + "GetRuleRequest", + "CreateRuleRequest", + "UpdateRuleRequest", + "DeleteRuleRequest", }, ) @@ -60,6 +58,7 @@ class Rule(proto.Message): If empty, this rule applies to all packages inside the repository. """ + class Action(proto.Enum): r"""Defines the action of the rule. @@ -157,10 +156,10 @@ class ListRulesResponse(proto.Message): def raw_page(self): return self - rules: MutableSequence['Rule'] = proto.RepeatedField( + rules: MutableSequence["Rule"] = proto.RepeatedField( proto.MESSAGE, number=1, - message='Rule', + message="Rule", ) next_page_token: str = proto.Field( proto.STRING, @@ -203,10 +202,10 @@ class CreateRuleRequest(proto.Message): proto.STRING, number=2, ) - rule: 'Rule' = proto.Field( + rule: "Rule" = proto.Field( proto.MESSAGE, number=3, - message='Rule', + message="Rule", ) @@ -223,10 +222,10 @@ class UpdateRuleRequest(proto.Message): https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask """ - rule: 'Rule' = proto.Field( + rule: "Rule" = proto.Field( proto.MESSAGE, number=1, - message='Rule', + message="Rule", ) update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/settings.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/settings.py index c05639001209..642896833e18 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/settings.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/settings.py @@ -46,6 +46,9 @@ class ProjectSettings(proto.Message): legacy_redirection_state (google.cloud.artifactregistry_v1.types.ProjectSettings.RedirectionState): The redirection state of the legacy repositories in this project. + pull_percent (int): + The percentage of pull traffic to redirect + from GCR to AR when using partial redirection. """ class RedirectionState(proto.Enum): @@ -61,11 +64,19 @@ class RedirectionState(proto.Enum): REDIRECTION_FROM_GCR_IO_FINALIZED (3): Redirection is enabled, and has been finalized so cannot be reverted. + REDIRECTION_FROM_GCR_IO_ENABLED_AND_COPYING (5): + Redirection is enabled and missing images are + copied from GCR + REDIRECTION_FROM_GCR_IO_PARTIAL_AND_COPYING (6): + Redirection is partially enabled and missing + images are copied from GCR """ REDIRECTION_STATE_UNSPECIFIED = 0 REDIRECTION_FROM_GCR_IO_DISABLED = 1 REDIRECTION_FROM_GCR_IO_ENABLED = 2 REDIRECTION_FROM_GCR_IO_FINALIZED = 3 + REDIRECTION_FROM_GCR_IO_ENABLED_AND_COPYING = 5 + REDIRECTION_FROM_GCR_IO_PARTIAL_AND_COPYING = 6 name: str = proto.Field( proto.STRING, @@ -76,6 +87,10 @@ class RedirectionState(proto.Enum): number=2, enum=RedirectionState, ) + pull_percent: int = proto.Field( + proto.INT32, + number=3, + ) class GetProjectSettingsRequest(proto.Message): diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/tag.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/tag.py index 96774bfd453d..62236adbcecf 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/tag.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/tag.py @@ -46,11 +46,10 @@ class Tag(proto.Message): escaped. The tag part can only have characters in [a-zA-Z0-9-._~:@], anything else must be URL encoded. version (str): - The name of the version the tag refers to, - for example: - "projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/sha256:5243811" - If the package or version ID parts contain - slashes, the slashes are escaped. + The name of the version the tag refers to, for example: + ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/sha256:5243811`` + If the package or version ID parts contain slashes, the + slashes are escaped. """ name: str = proto.Field( @@ -76,16 +75,34 @@ class ListTagsRequest(proto.Message): Filter rules are case insensitive. The fields eligible for filtering are: + - ``name`` - ``version`` - An example of using a filter: + Examples of using a filter: - - ``version="projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/1.0"`` - --> Tags that are applied to the version ``1.0`` in - package ``pkg1``. + To filter the results of your request to tags with the name + ``my-tag`` in package ``my-package`` in repository + ``my-repo`` in project "``y-project`` in the us-central + region, append the following filter expression to your + request: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/tags/my-tag"`` + + You can also use wildcards to match any number of characters + before or after the value: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/tags/my*"`` + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/tags/*tag"`` + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/tags/*tag*"`` + + To filter the results of your request to tags applied to the + version ``1.0`` in package ``my-package``, append the + following filter expression to your request: + + - ``version="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/1.0"`` page_size (int): The maximum number of tags to return. Maximum - page size is 10,000. + page size is 1,000. page_token (str): The next_page_token value returned from a previous list request, if any. diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/version.py index 01ddc755b786..de1064f1cb9f 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/version.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/types/version.py @@ -17,6 +17,7 @@ from typing import MutableMapping, MutableSequence +from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore @@ -34,6 +35,7 @@ "DeleteVersionRequest", "BatchDeleteVersionsRequest", "BatchDeleteVersionsMetadata", + "UpdateVersionRequest", }, ) @@ -65,10 +67,9 @@ class Version(proto.Message): Attributes: name (str): The name of the version, for example: - - "projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/art1". - If the package or version ID parts contain - slashes, the slashes are escaped. + ``projects/p1/locations/us-central1/repositories/repo1/packages/pkg1/versions/art1``. + If the package or version ID parts contain slashes, the + slashes are escaped. description (str): Optional. Description of the version, as specified in its metadata. @@ -87,6 +88,8 @@ class Version(proto.Message): resources could be: [DockerImage][google.devtools.artifactregistry.v1.DockerImage] [MavenArtifact][google.devtools.artifactregistry.v1.MavenArtifact] + annotations (MutableMapping[str, str]): + Optional. Client specified annotations. """ name: str = proto.Field( @@ -117,6 +120,11 @@ class Version(proto.Message): number=8, message=struct_pb2.Struct, ) + annotations: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=9, + ) class ListVersionsRequest(proto.Message): @@ -137,6 +145,56 @@ class ListVersionsRequest(proto.Message): response. order_by (str): Optional. The field to order the results by. + filter (str): + Optional. An expression for filtering the results of the + request. Filter rules are case insensitive. The fields + eligible for filtering are: + + - ``name`` + - ``annotations`` + + Examples of using a filter: + + To filter the results of your request to versions with the + name ``my-version`` in project ``my-project`` in the + ``us-central`` region, in repository ``my-repo``, append the + following filter expression to your request: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/my-version"`` + + You can also use wildcards to match any number of characters + before or after the value: + + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/*version"`` + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/my*"`` + - ``name="projects/my-project/locations/us-central1/repositories/my-repo/packages/my-package/versions/*version*"`` + + To filter the results of your request to versions with the + annotation key-value pair [``external_link``: + ``external_link_value``], append the following filter + expression to your request: + + - ``"annotations.external_link:external_link_value"`` + + To filter just for a specific annotation key + ``external_link``, append the following filter expression to + your request: + + - ``"annotations.external_link"`` + + If the annotation key or value contains special characters, + you can escape them by surrounding the value with backticks. + For example, to filter the results of your request to + versions with the annotation key-value pair + [``external.link``:``https://example.com/my-version``], + append the following filter expression to your request: + + - :literal:`"annotations.`external.link`:`https://example.com/my-version`"` + + You can also filter with annotations with a wildcard to + match any number of characters before or after the value: + + - :literal:`"annotations.*_link:`*example.com*`"` """ parent: str = proto.Field( @@ -160,6 +218,10 @@ class ListVersionsRequest(proto.Message): proto.STRING, number=5, ) + filter: str = proto.Field( + proto.STRING, + number=6, + ) class ListVersionsResponse(proto.Message): @@ -277,4 +339,29 @@ class BatchDeleteVersionsMetadata(proto.Message): ) +class UpdateVersionRequest(proto.Message): + r"""The request to update a version. + + Attributes: + version (google.cloud.artifactregistry_v1.types.Version): + Required. The Version that replaces the + resource on the server. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + version: "Version" = proto.Field( + proto.MESSAGE, + number=1, + message="Version", + ) + 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/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py index 739fdfae141c..558c8aab67c5 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py +++ b/packages/google-cloud-artifact-registry/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.12.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_create_rule_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_file_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_attachment_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_get_rule_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_attachments_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_list_rules_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_file_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_package_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_rule_sync.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_async.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_async.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_async.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_async.py diff --git a/owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_sync.py b/packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_sync.py similarity index 100% rename from owl-bot-staging/google-cloud-artifact-registry/v1/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_sync.py rename to packages/google-cloud-artifact-registry/samples/generated_samples/artifactregistry_v1_generated_artifact_registry_update_version_sync.py diff --git a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json index d0e149f3a0f0..a1f492c7ad92 100644 --- a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json +++ b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-artifact-registry", - "version": "1.12.0" + "version": "0.1.0" }, "snippets": [ { @@ -188,30 +188,30 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_attachment", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateAttachment", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "CreateRepository" + "shortName": "CreateAttachment" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateRepositoryRequest" + "type": "google.cloud.artifactregistry_v1.types.CreateAttachmentRequest" }, { "name": "parent", "type": "str" }, { - "name": "repository", - "type": "google.cloud.artifactregistry_v1.types.Repository" + "name": "attachment", + "type": "google.cloud.artifactregistry_v1.types.Attachment" }, { - "name": "repository_id", + "name": "attachment_id", "type": "str" }, { @@ -228,21 +228,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_repository" + "shortName": "create_attachment" }, - "description": "Sample for CreateRepository", - "file": "artifactregistry_v1_generated_artifact_registry_create_repository_async.py", + "description": "Sample for CreateAttachment", + "file": "artifactregistry_v1_generated_artifact_registry_create_attachment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRepository_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateAttachment_async", "segments": [ { - "end": 56, + "end": 61, "start": 27, "type": "FULL" }, { - "end": 56, + "end": 61, "start": 27, "type": "SHORT" }, @@ -252,22 +252,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 51, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 53, - "start": 47, + "end": 58, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 57, - "start": 54, + "end": 62, + "start": 59, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_create_repository_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_create_attachment_async.py" }, { "canonical": true, @@ -276,30 +276,30 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_attachment", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateAttachment", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "CreateRepository" + "shortName": "CreateAttachment" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateRepositoryRequest" + "type": "google.cloud.artifactregistry_v1.types.CreateAttachmentRequest" }, { "name": "parent", "type": "str" }, { - "name": "repository", - "type": "google.cloud.artifactregistry_v1.types.Repository" + "name": "attachment", + "type": "google.cloud.artifactregistry_v1.types.Attachment" }, { - "name": "repository_id", + "name": "attachment_id", "type": "str" }, { @@ -316,21 +316,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "create_repository" + "shortName": "create_attachment" }, - "description": "Sample for CreateRepository", - "file": "artifactregistry_v1_generated_artifact_registry_create_repository_sync.py", + "description": "Sample for CreateAttachment", + "file": "artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRepository_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateAttachment_sync", "segments": [ { - "end": 56, + "end": 61, "start": 27, "type": "FULL" }, { - "end": 56, + "end": 61, "start": 27, "type": "SHORT" }, @@ -340,22 +340,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 51, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 53, - "start": 47, + "end": 58, + "start": 52, "type": "REQUEST_EXECUTION" }, { - "end": 57, - "start": 54, + "end": 62, + "start": 59, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_create_repository_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_create_attachment_sync.py" }, { "canonical": true, @@ -365,30 +365,30 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "CreateTag" + "shortName": "CreateRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateTagRequest" + "type": "google.cloud.artifactregistry_v1.types.CreateRepositoryRequest" }, { "name": "parent", "type": "str" }, { - "name": "tag", - "type": "google.cloud.artifactregistry_v1.types.Tag" + "name": "repository", + "type": "google.cloud.artifactregistry_v1.types.Repository" }, { - "name": "tag_id", + "name": "repository_id", "type": "str" }, { @@ -404,22 +404,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "create_tag" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_repository" }, - "description": "Sample for CreateTag", - "file": "artifactregistry_v1_generated_artifact_registry_create_tag_async.py", + "description": "Sample for CreateRepository", + "file": "artifactregistry_v1_generated_artifact_registry_create_repository_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateTag_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRepository_async", "segments": [ { - "end": 50, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 56, "start": 27, "type": "SHORT" }, @@ -429,22 +429,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_create_tag_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_create_repository_async.py" }, { "canonical": true, @@ -453,30 +453,30 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "CreateTag" + "shortName": "CreateRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.CreateTagRequest" + "type": "google.cloud.artifactregistry_v1.types.CreateRepositoryRequest" }, { "name": "parent", "type": "str" }, { - "name": "tag", - "type": "google.cloud.artifactregistry_v1.types.Tag" + "name": "repository", + "type": "google.cloud.artifactregistry_v1.types.Repository" }, { - "name": "tag_id", + "name": "repository_id", "type": "str" }, { @@ -492,22 +492,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "create_tag" + "resultType": "google.api_core.operation.Operation", + "shortName": "create_repository" }, - "description": "Sample for CreateTag", - "file": "artifactregistry_v1_generated_artifact_registry_create_tag_sync.py", + "description": "Sample for CreateRepository", + "file": "artifactregistry_v1_generated_artifact_registry_create_repository_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateTag_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRepository_sync", "segments": [ { - "end": 50, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 56, "start": 27, "type": "SHORT" }, @@ -517,22 +517,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 47, - "start": 45, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 51, - "start": 48, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_create_tag_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_create_repository_sync.py" }, { "canonical": true, @@ -542,22 +542,30 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_rule", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeletePackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRule", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "DeletePackage" + "shortName": "CreateRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeletePackageRequest" + "type": "google.cloud.artifactregistry_v1.types.CreateRuleRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "rule", + "type": "google.cloud.artifactregistry_v1.types.Rule" + }, + { + "name": "rule_id", "type": "str" }, { @@ -573,22 +581,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_package" + "resultType": "google.cloud.artifactregistry_v1.types.Rule", + "shortName": "create_rule" }, - "description": "Sample for DeletePackage", - "file": "artifactregistry_v1_generated_artifact_registry_delete_package_async.py", + "description": "Sample for CreateRule", + "file": "artifactregistry_v1_generated_artifact_registry_create_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeletePackage_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRule_async", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -603,17 +611,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 52, + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_package_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_create_rule_async.py" }, { "canonical": true, @@ -622,22 +630,30 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_rule", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeletePackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateRule", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "DeletePackage" + "shortName": "CreateRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeletePackageRequest" + "type": "google.cloud.artifactregistry_v1.types.CreateRuleRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "rule", + "type": "google.cloud.artifactregistry_v1.types.Rule" + }, + { + "name": "rule_id", "type": "str" }, { @@ -653,22 +669,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_package" + "resultType": "google.cloud.artifactregistry_v1.types.Rule", + "shortName": "create_rule" }, - "description": "Sample for DeletePackage", - "file": "artifactregistry_v1_generated_artifact_registry_delete_package_sync.py", + "description": "Sample for CreateRule", + "file": "artifactregistry_v1_generated_artifact_registry_create_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeletePackage_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateRule_sync", "segments": [ { - "end": 55, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 51, "start": 27, "type": "SHORT" }, @@ -683,17 +699,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 52, + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_package_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_create_rule_sync.py" }, { "canonical": true, @@ -703,22 +719,30 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.create_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "DeleteRepository" + "shortName": "CreateTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteRepositoryRequest" + "type": "google.cloud.artifactregistry_v1.types.CreateTagRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "tag", + "type": "google.cloud.artifactregistry_v1.types.Tag" + }, + { + "name": "tag_id", "type": "str" }, { @@ -734,22 +758,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_repository" + "resultType": "google.cloud.artifactregistry_v1.types.Tag", + "shortName": "create_tag" }, - "description": "Sample for DeleteRepository", - "file": "artifactregistry_v1_generated_artifact_registry_delete_repository_async.py", + "description": "Sample for CreateTag", + "file": "artifactregistry_v1_generated_artifact_registry_create_tag_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRepository_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateTag_async", "segments": [ { - "end": 55, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 50, "start": 27, "type": "SHORT" }, @@ -759,22 +783,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_repository_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_create_tag_async.py" }, { "canonical": true, @@ -783,22 +807,30 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.create_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.CreateTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "DeleteRepository" + "shortName": "CreateTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteRepositoryRequest" + "type": "google.cloud.artifactregistry_v1.types.CreateTagRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "tag", + "type": "google.cloud.artifactregistry_v1.types.Tag" + }, + { + "name": "tag_id", "type": "str" }, { @@ -814,22 +846,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_repository" + "resultType": "google.cloud.artifactregistry_v1.types.Tag", + "shortName": "create_tag" }, - "description": "Sample for DeleteRepository", - "file": "artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py", + "description": "Sample for CreateTag", + "file": "artifactregistry_v1_generated_artifact_registry_create_tag_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRepository_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_CreateTag_sync", "segments": [ { - "end": 55, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 50, "start": 27, "type": "SHORT" }, @@ -839,22 +871,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_create_tag_sync.py" }, { "canonical": true, @@ -864,19 +896,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_attachment", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteAttachment", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "DeleteTag" + "shortName": "DeleteAttachment" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteTagRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteAttachmentRequest" }, { "name": "name", @@ -895,21 +927,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_tag" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_attachment" }, - "description": "Sample for DeleteTag", - "file": "artifactregistry_v1_generated_artifact_registry_delete_tag_async.py", + "description": "Sample for DeleteAttachment", + "file": "artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteTag_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteAttachment_async", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, @@ -919,20 +952,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 45, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_tag_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_attachment_async.py" }, { "canonical": true, @@ -941,19 +976,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_attachment", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteAttachment", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "DeleteTag" + "shortName": "DeleteAttachment" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteTagRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteAttachmentRequest" }, { "name": "name", @@ -972,21 +1007,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_tag" + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_attachment" }, - "description": "Sample for DeleteTag", - "file": "artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py", + "description": "Sample for DeleteAttachment", + "file": "artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteTag_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteAttachment_sync", "segments": [ { - "end": 48, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 48, + "end": 55, "start": 27, "type": "SHORT" }, @@ -996,20 +1032,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 45, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_attachment_sync.py" }, { "canonical": true, @@ -1019,19 +1057,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_version", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_file", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteVersion", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteFile", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "DeleteVersion" + "shortName": "DeleteFile" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteVersionRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteFileRequest" }, { "name": "name", @@ -1051,21 +1089,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_version" + "shortName": "delete_file" }, - "description": "Sample for DeleteVersion", - "file": "artifactregistry_v1_generated_artifact_registry_delete_version_async.py", + "description": "Sample for DeleteFile", + "file": "artifactregistry_v1_generated_artifact_registry_delete_file_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteVersion_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteFile_async", "segments": [ { - "end": 54, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1075,22 +1113,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 51, - "start": 45, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_version_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_file_async.py" }, { "canonical": true, @@ -1099,19 +1137,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_version", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_file", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteVersion", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteFile", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "DeleteVersion" + "shortName": "DeleteFile" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.DeleteVersionRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteFileRequest" }, { "name": "name", @@ -1131,21 +1169,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "delete_version" + "shortName": "delete_file" }, - "description": "Sample for DeleteVersion", - "file": "artifactregistry_v1_generated_artifact_registry_delete_version_sync.py", + "description": "Sample for DeleteFile", + "file": "artifactregistry_v1_generated_artifact_registry_delete_file_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteVersion_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteFile_sync", "segments": [ { - "end": 54, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1155,22 +1193,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 44, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 51, - "start": 45, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 55, - "start": 52, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_delete_version_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_file_sync.py" }, { "canonical": true, @@ -1180,19 +1218,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_docker_image", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetDockerImage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeletePackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetDockerImage" + "shortName": "DeletePackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetDockerImageRequest" + "type": "google.cloud.artifactregistry_v1.types.DeletePackageRequest" }, { "name": "name", @@ -1211,22 +1249,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.DockerImage", - "shortName": "get_docker_image" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_package" }, - "description": "Sample for GetDockerImage", - "file": "artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py", + "description": "Sample for DeletePackage", + "file": "artifactregistry_v1_generated_artifact_registry_delete_package_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetDockerImage_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeletePackage_async", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1241,17 +1279,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_package_async.py" }, { "canonical": true, @@ -1260,19 +1298,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_docker_image", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetDockerImage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeletePackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetDockerImage" + "shortName": "DeletePackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetDockerImageRequest" + "type": "google.cloud.artifactregistry_v1.types.DeletePackageRequest" }, { "name": "name", @@ -1291,22 +1329,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.DockerImage", - "shortName": "get_docker_image" + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_package" }, - "description": "Sample for GetDockerImage", - "file": "artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py", + "description": "Sample for DeletePackage", + "file": "artifactregistry_v1_generated_artifact_registry_delete_package_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetDockerImage_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeletePackage_sync", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1321,17 +1359,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_package_sync.py" }, { "canonical": true, @@ -1341,19 +1379,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_file", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetFile", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetFile" + "shortName": "DeleteRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetFileRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteRepositoryRequest" }, { "name": "name", @@ -1372,22 +1410,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.File", - "shortName": "get_file" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_repository" }, - "description": "Sample for GetFile", - "file": "artifactregistry_v1_generated_artifact_registry_get_file_async.py", + "description": "Sample for DeleteRepository", + "file": "artifactregistry_v1_generated_artifact_registry_delete_repository_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetFile_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRepository_async", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1402,17 +1440,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_file_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_repository_async.py" }, { "canonical": true, @@ -1421,19 +1459,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_file", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetFile", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetFile" + "shortName": "DeleteRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetFileRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteRepositoryRequest" }, { "name": "name", @@ -1452,22 +1490,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.File", - "shortName": "get_file" + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_repository" }, - "description": "Sample for GetFile", - "file": "artifactregistry_v1_generated_artifact_registry_get_file_sync.py", + "description": "Sample for DeleteRepository", + "file": "artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetFile_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRepository_sync", "segments": [ { - "end": 51, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 55, "start": 27, "type": "SHORT" }, @@ -1482,17 +1520,17 @@ "type": "REQUEST_INITIALIZATION" }, { - "end": 48, + "end": 52, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_file_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_repository_sync.py" }, { "canonical": true, @@ -1502,19 +1540,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_iam_policy", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_rule", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetIamPolicy", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRule", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetIamPolicy" + "shortName": "DeleteRule" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteRuleRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -1529,47 +1571,44 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy" + "shortName": "delete_rule" }, - "description": "Sample for GetIamPolicy", - "file": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py", + "description": "Sample for DeleteRule", + "file": "artifactregistry_v1_generated_artifact_registry_delete_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetIamPolicy_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRule_async", "segments": [ { - "end": 52, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 46, - "start": 42, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_rule_async.py" }, { "canonical": true, @@ -1578,23 +1617,27 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_iam_policy", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_rule", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetIamPolicy", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteRule", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetIamPolicy" + "shortName": "DeleteRule" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteRuleRequest" }, { - "name": "retry", - "type": "google.api_core.retry.Retry" + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" }, { "name": "timeout", @@ -1605,47 +1648,44 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy" + "shortName": "delete_rule" }, - "description": "Sample for GetIamPolicy", - "file": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py", + "description": "Sample for DeleteRule", + "file": "artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetIamPolicy_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteRule_sync", "segments": [ { - "end": 52, + "end": 49, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 49, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 46, - "start": 42, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 50, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_rule_sync.py" }, { "canonical": true, @@ -1655,19 +1695,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_maven_artifact", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetMavenArtifact", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetMavenArtifact" + "shortName": "DeleteTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteTagRequest" }, { "name": "name", @@ -1686,22 +1726,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.MavenArtifact", - "shortName": "get_maven_artifact" + "shortName": "delete_tag" }, - "description": "Sample for GetMavenArtifact", - "file": "artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py", + "description": "Sample for DeleteTag", + "file": "artifactregistry_v1_generated_artifact_registry_delete_tag_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteTag_async", "segments": [ { - "end": 51, + "end": 48, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 48, "start": 27, "type": "SHORT" }, @@ -1711,22 +1750,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_maven_artifact_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_tag_async.py" }, { "canonical": true, @@ -1735,19 +1772,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_maven_artifact", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetMavenArtifact", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetMavenArtifact" + "shortName": "DeleteTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteTagRequest" }, { "name": "name", @@ -1766,22 +1803,21 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.MavenArtifact", - "shortName": "get_maven_artifact" + "shortName": "delete_tag" }, - "description": "Sample for GetMavenArtifact", - "file": "artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py", + "description": "Sample for DeleteTag", + "file": "artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteTag_sync", "segments": [ { - "end": 51, + "end": 48, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 48, "start": 27, "type": "SHORT" }, @@ -1791,22 +1827,20 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_maven_artifact_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_tag_sync.py" }, { "canonical": true, @@ -1816,19 +1850,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_npm_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.delete_version", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetNpmPackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteVersion", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetNpmPackage" + "shortName": "DeleteVersion" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetNpmPackageRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteVersionRequest" }, { "name": "name", @@ -1847,22 +1881,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.NpmPackage", - "shortName": "get_npm_package" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_version" }, - "description": "Sample for GetNpmPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py", + "description": "Sample for DeleteVersion", + "file": "artifactregistry_v1_generated_artifact_registry_delete_version_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteVersion_async", "segments": [ { - "end": 51, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 54, "start": 27, "type": "SHORT" }, @@ -1872,22 +1906,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_version_async.py" }, { "canonical": true, @@ -1896,19 +1930,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_npm_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.delete_version", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetNpmPackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.DeleteVersion", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetNpmPackage" + "shortName": "DeleteVersion" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetNpmPackageRequest" + "type": "google.cloud.artifactregistry_v1.types.DeleteVersionRequest" }, { "name": "name", @@ -1927,22 +1961,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.NpmPackage", - "shortName": "get_npm_package" + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_version" }, - "description": "Sample for GetNpmPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py", + "description": "Sample for DeleteVersion", + "file": "artifactregistry_v1_generated_artifact_registry_delete_version_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_DeleteVersion_sync", "segments": [ { - "end": 51, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 54, "start": 27, "type": "SHORT" }, @@ -1952,22 +1986,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_delete_version_sync.py" }, { "canonical": true, @@ -1977,19 +2011,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_attachment", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetAttachment", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetPackage" + "shortName": "GetAttachment" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" + "type": "google.cloud.artifactregistry_v1.types.GetAttachmentRequest" }, { "name": "name", @@ -2008,14 +2042,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Package", - "shortName": "get_package" + "resultType": "google.cloud.artifactregistry_v1.types.Attachment", + "shortName": "get_attachment" }, - "description": "Sample for GetPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_package_async.py", + "description": "Sample for GetAttachment", + "file": "artifactregistry_v1_generated_artifact_registry_get_attachment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetAttachment_async", "segments": [ { "end": 51, @@ -2048,7 +2082,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_package_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_attachment_async.py" }, { "canonical": true, @@ -2057,19 +2091,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_attachment", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetAttachment", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetPackage" + "shortName": "GetAttachment" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" + "type": "google.cloud.artifactregistry_v1.types.GetAttachmentRequest" }, { "name": "name", @@ -2088,14 +2122,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Package", - "shortName": "get_package" + "resultType": "google.cloud.artifactregistry_v1.types.Attachment", + "shortName": "get_attachment" }, - "description": "Sample for GetPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_package_sync.py", + "description": "Sample for GetAttachment", + "file": "artifactregistry_v1_generated_artifact_registry_get_attachment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetAttachment_sync", "segments": [ { "end": 51, @@ -2128,7 +2162,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_package_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_attachment_sync.py" }, { "canonical": true, @@ -2138,19 +2172,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_docker_image", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetDockerImage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetProjectSettings" + "shortName": "GetDockerImage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetDockerImageRequest" }, { "name": "name", @@ -2169,14 +2203,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", - "shortName": "get_project_settings" + "resultType": "google.cloud.artifactregistry_v1.types.DockerImage", + "shortName": "get_docker_image" }, - "description": "Sample for GetProjectSettings", - "file": "artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py", + "description": "Sample for GetDockerImage", + "file": "artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetDockerImage_async", "segments": [ { "end": 51, @@ -2209,7 +2243,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_project_settings_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_docker_image_async.py" }, { "canonical": true, @@ -2218,19 +2252,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_docker_image", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetDockerImage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetProjectSettings" + "shortName": "GetDockerImage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetDockerImageRequest" }, { "name": "name", @@ -2249,14 +2283,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", - "shortName": "get_project_settings" + "resultType": "google.cloud.artifactregistry_v1.types.DockerImage", + "shortName": "get_docker_image" }, - "description": "Sample for GetProjectSettings", - "file": "artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py", + "description": "Sample for GetDockerImage", + "file": "artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetDockerImage_sync", "segments": [ { "end": 51, @@ -2289,7 +2323,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_project_settings_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_docker_image_sync.py" }, { "canonical": true, @@ -2299,19 +2333,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_python_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_file", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPythonPackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetFile", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetPythonPackage" + "shortName": "GetFile" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPythonPackageRequest" + "type": "google.cloud.artifactregistry_v1.types.GetFileRequest" }, { "name": "name", @@ -2330,14 +2364,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.PythonPackage", - "shortName": "get_python_package" + "resultType": "google.cloud.artifactregistry_v1.types.File", + "shortName": "get_file" }, - "description": "Sample for GetPythonPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_python_package_async.py", + "description": "Sample for GetFile", + "file": "artifactregistry_v1_generated_artifact_registry_get_file_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetFile_async", "segments": [ { "end": 51, @@ -2370,7 +2404,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_python_package_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_file_async.py" }, { "canonical": true, @@ -2379,19 +2413,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_python_package", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_file", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPythonPackage", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetFile", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetPythonPackage" + "shortName": "GetFile" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetPythonPackageRequest" + "type": "google.cloud.artifactregistry_v1.types.GetFileRequest" }, { "name": "name", @@ -2410,14 +2444,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.PythonPackage", - "shortName": "get_python_package" + "resultType": "google.cloud.artifactregistry_v1.types.File", + "shortName": "get_file" }, - "description": "Sample for GetPythonPackage", - "file": "artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py", + "description": "Sample for GetFile", + "file": "artifactregistry_v1_generated_artifact_registry_get_file_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetFile_sync", "segments": [ { "end": 51, @@ -2450,7 +2484,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_file_sync.py" }, { "canonical": true, @@ -2460,23 +2494,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_iam_policy", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetIamPolicy", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetRepository" + "shortName": "GetIamPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" - }, - { - "name": "name", - "type": "str" + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" }, { "name": "retry", @@ -2491,47 +2521,47 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Repository", - "shortName": "get_repository" + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, - "description": "Sample for GetRepository", - "file": "artifactregistry_v1_generated_artifact_registry_get_repository_async.py", + "description": "Sample for GetIamPolicy", + "file": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetIamPolicy_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 40, - "start": 38, + "end": 41, + "start": 39, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 41, + "end": 46, + "start": 42, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_repository_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_async.py" }, { "canonical": true, @@ -2540,23 +2570,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_iam_policy", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetIamPolicy", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetRepository" + "shortName": "GetIamPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" - }, - { - "name": "name", - "type": "str" + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" }, { "name": "retry", @@ -2571,47 +2597,47 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Repository", - "shortName": "get_repository" + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, - "description": "Sample for GetRepository", - "file": "artifactregistry_v1_generated_artifact_registry_get_repository_sync.py", + "description": "Sample for GetIamPolicy", + "file": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetIamPolicy_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, { - "end": 40, - "start": 38, + "end": 41, + "start": 39, "type": "CLIENT_INITIALIZATION" }, { - "end": 45, - "start": 41, + "end": 46, + "start": 42, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 49, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 53, + "start": 50, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_repository_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_iam_policy_sync.py" }, { "canonical": true, @@ -2621,19 +2647,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_maven_artifact", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetMavenArtifact", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetTag" + "shortName": "GetMavenArtifact" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" + "type": "google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest" }, { "name": "name", @@ -2652,22 +2678,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "get_tag" + "resultType": "google.cloud.artifactregistry_v1.types.MavenArtifact", + "shortName": "get_maven_artifact" }, - "description": "Sample for GetTag", - "file": "artifactregistry_v1_generated_artifact_registry_get_tag_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_GetTag_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_async", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2677,22 +2703,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_maven_artifact_async.py" }, { "canonical": true, @@ -2701,19 +2727,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_maven_artifact", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetMavenArtifact", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetTag" + "shortName": "GetMavenArtifact" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" + "type": "google.cloud.artifactregistry_v1.types.GetMavenArtifactRequest" }, { "name": "name", @@ -2732,22 +2758,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "get_tag" + "resultType": "google.cloud.artifactregistry_v1.types.MavenArtifact", + "shortName": "get_maven_artifact" }, - "description": "Sample for GetTag", - "file": "artifactregistry_v1_generated_artifact_registry_get_tag_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_GetTag_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetMavenArtifact_sync", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2757,22 +2783,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_maven_artifact_sync.py" }, { "canonical": true, @@ -2782,19 +2808,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_vpcsc_config", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_npm_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVPCSCConfig", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetNpmPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetVPCSCConfig" + "shortName": "GetNpmPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetVPCSCConfigRequest" + "type": "google.cloud.artifactregistry_v1.types.GetNpmPackageRequest" }, { "name": "name", @@ -2813,14 +2839,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", - "shortName": "get_vpcsc_config" + "resultType": "google.cloud.artifactregistry_v1.types.NpmPackage", + "shortName": "get_npm_package" }, - "description": "Sample for GetVPCSCConfig", - "file": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_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_GetVPCSCConfig_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_async", "segments": [ { "end": 51, @@ -2853,7 +2879,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_npm_package_async.py" }, { "canonical": true, @@ -2862,19 +2888,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_vpcsc_config", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_npm_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVPCSCConfig", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetNpmPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetVPCSCConfig" + "shortName": "GetNpmPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetVPCSCConfigRequest" + "type": "google.cloud.artifactregistry_v1.types.GetNpmPackageRequest" }, { "name": "name", @@ -2893,14 +2919,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", - "shortName": "get_vpcsc_config" + "resultType": "google.cloud.artifactregistry_v1.types.NpmPackage", + "shortName": "get_npm_package" }, - "description": "Sample for GetVPCSCConfig", - "file": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_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_GetVPCSCConfig_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetNpmPackage_sync", "segments": [ { "end": 51, @@ -2933,7 +2959,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_npm_package_sync.py" }, { "canonical": true, @@ -2943,19 +2969,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_version", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVersion", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetVersion" + "shortName": "GetPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetVersionRequest" + "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" }, { "name": "name", @@ -2974,22 +3000,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Version", - "shortName": "get_version" + "resultType": "google.cloud.artifactregistry_v1.types.Package", + "shortName": "get_package" }, - "description": "Sample for GetVersion", - "file": "artifactregistry_v1_generated_artifact_registry_get_version_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_GetVersion_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_async", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -2999,22 +3025,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_package_async.py" }, { "canonical": true, @@ -3023,19 +3049,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_version", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVersion", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "GetVersion" + "shortName": "GetPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.GetVersionRequest" + "type": "google.cloud.artifactregistry_v1.types.GetPackageRequest" }, { "name": "name", @@ -3054,22 +3080,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Version", - "shortName": "get_version" + "resultType": "google.cloud.artifactregistry_v1.types.Package", + "shortName": "get_package" }, - "description": "Sample for GetVersion", - "file": "artifactregistry_v1_generated_artifact_registry_get_version_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_GetVersion_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPackage_sync", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3079,22 +3105,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_package_sync.py" }, { "canonical": true, @@ -3104,19 +3130,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_project_settings", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportAptArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ImportAptArtifacts" + "shortName": "GetProjectSettings" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -3131,22 +3161,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "import_apt_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", + "shortName": "get_project_settings" }, - "description": "Sample for ImportAptArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_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_ImportAptArtifacts_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_async", "segments": [ { - "end": 54, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3156,22 +3186,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_project_settings_async.py" }, { "canonical": true, @@ -3180,19 +3210,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_project_settings", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportAptArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetProjectSettings", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ImportAptArtifacts" + "shortName": "GetProjectSettings" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetProjectSettingsRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -3207,22 +3241,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "import_apt_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", + "shortName": "get_project_settings" }, - "description": "Sample for ImportAptArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_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_ImportAptArtifacts_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetProjectSettings_sync", "segments": [ { - "end": 54, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3232,22 +3266,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_project_settings_sync.py" }, { "canonical": true, @@ -3257,19 +3291,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_python_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportYumArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPythonPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ImportYumArtifacts" + "shortName": "GetPythonPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetPythonPackageRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -3284,22 +3322,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "import_yum_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.PythonPackage", + "shortName": "get_python_package" }, - "description": "Sample for ImportYumArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_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_ImportYumArtifacts_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_async", "segments": [ { - "end": 54, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3309,22 +3347,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_yum_artifacts_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_python_package_async.py" }, { "canonical": true, @@ -3333,19 +3371,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_python_package", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportYumArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetPythonPackage", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ImportYumArtifacts" + "shortName": "GetPythonPackage" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetPythonPackageRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -3360,22 +3402,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.api_core.operation.Operation", - "shortName": "import_yum_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.PythonPackage", + "shortName": "get_python_package" }, - "description": "Sample for ImportYumArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_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_ImportYumArtifacts_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetPythonPackage_sync", "segments": [ { - "end": 54, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 54, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3385,22 +3427,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_yum_artifacts_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_python_package_sync.py" }, { "canonical": true, @@ -3410,22 +3452,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_docker_images", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListDockerImages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListDockerImages" + "shortName": "GetRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListDockerImagesRequest" + "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3441,22 +3483,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesAsyncPager", - "shortName": "list_docker_images" + "resultType": "google.cloud.artifactregistry_v1.types.Repository", + "shortName": "get_repository" }, - "description": "Sample for ListDockerImages", - "file": "artifactregistry_v1_generated_artifact_registry_list_docker_images_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_ListDockerImages_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_async", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3476,12 +3518,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_repository_async.py" }, { "canonical": true, @@ -3490,22 +3532,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_docker_images", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListDockerImages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListDockerImages" + "shortName": "GetRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListDockerImagesRequest" + "type": "google.cloud.artifactregistry_v1.types.GetRepositoryRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3521,22 +3563,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesPager", - "shortName": "list_docker_images" + "resultType": "google.cloud.artifactregistry_v1.types.Repository", + "shortName": "get_repository" }, - "description": "Sample for ListDockerImages", - "file": "artifactregistry_v1_generated_artifact_registry_list_docker_images_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_ListDockerImages_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRepository_sync", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3556,12 +3598,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_repository_sync.py" }, { "canonical": true, @@ -3571,22 +3613,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_files", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_rule", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListFiles", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRule", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListFiles" + "shortName": "GetRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListFilesRequest" + "type": "google.cloud.artifactregistry_v1.types.GetRuleRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3602,22 +3644,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesAsyncPager", - "shortName": "list_files" + "resultType": "google.cloud.artifactregistry_v1.types.Rule", + "shortName": "get_rule" }, - "description": "Sample for ListFiles", - "file": "artifactregistry_v1_generated_artifact_registry_list_files_async.py", + "description": "Sample for GetRule", + "file": "artifactregistry_v1_generated_artifact_registry_get_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListFiles_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRule_async", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3637,12 +3679,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_files_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_rule_async.py" }, { "canonical": true, @@ -3651,22 +3693,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_files", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_rule", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListFiles", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetRule", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListFiles" + "shortName": "GetRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListFilesRequest" + "type": "google.cloud.artifactregistry_v1.types.GetRuleRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3682,22 +3724,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesPager", - "shortName": "list_files" + "resultType": "google.cloud.artifactregistry_v1.types.Rule", + "shortName": "get_rule" }, - "description": "Sample for ListFiles", - "file": "artifactregistry_v1_generated_artifact_registry_list_files_sync.py", + "description": "Sample for GetRule", + "file": "artifactregistry_v1_generated_artifact_registry_get_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListFiles_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetRule_sync", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3717,12 +3759,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_files_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_rule_sync.py" }, { "canonical": true, @@ -3732,22 +3774,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_maven_artifacts", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListMavenArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListMavenArtifacts" + "shortName": "GetTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListMavenArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3763,22 +3805,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsAsyncPager", - "shortName": "list_maven_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.Tag", + "shortName": "get_tag" }, - "description": "Sample for ListMavenArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_list_maven_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_ListMavenArtifacts_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetTag_async", "segments": [ { - "end": 52, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 50, "start": 27, "type": "SHORT" }, @@ -3788,22 +3830,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_tag_async.py" }, { "canonical": true, @@ -3812,22 +3854,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_maven_artifacts", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListMavenArtifacts", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListMavenArtifacts" + "shortName": "GetTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListMavenArtifactsRequest" + "type": "google.cloud.artifactregistry_v1.types.GetTagRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3843,22 +3885,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsPager", - "shortName": "list_maven_artifacts" + "resultType": "google.cloud.artifactregistry_v1.types.Tag", + "shortName": "get_tag" }, - "description": "Sample for ListMavenArtifacts", - "file": "artifactregistry_v1_generated_artifact_registry_list_maven_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_ListMavenArtifacts_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetTag_sync", "segments": [ { - "end": 52, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 50, "start": 27, "type": "SHORT" }, @@ -3868,22 +3910,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_maven_artifacts_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_tag_sync.py" }, { "canonical": true, @@ -3893,22 +3935,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_npm_packages", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_vpcsc_config", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListNpmPackages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVPCSCConfig", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListNpmPackages" + "shortName": "GetVPCSCConfig" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest" + "type": "google.cloud.artifactregistry_v1.types.GetVPCSCConfigRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -3924,22 +3966,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesAsyncPager", - "shortName": "list_npm_packages" + "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", + "shortName": "get_vpcsc_config" }, - "description": "Sample for ListNpmPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py", + "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_ListNpmPackages_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVPCSCConfig_async", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -3959,12 +4001,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_npm_packages_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_async.py" }, { "canonical": true, @@ -3973,22 +4015,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_npm_packages", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_vpcsc_config", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListNpmPackages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVPCSCConfig", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListNpmPackages" + "shortName": "GetVPCSCConfig" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest" + "type": "google.cloud.artifactregistry_v1.types.GetVPCSCConfigRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -4004,22 +4046,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesPager", - "shortName": "list_npm_packages" + "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", + "shortName": "get_vpcsc_config" }, - "description": "Sample for ListNpmPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py", + "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_ListNpmPackages_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVPCSCConfig_sync", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -4039,12 +4081,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 53, + "end": 52, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_npm_packages_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_vpcsc_config_sync.py" }, { "canonical": true, @@ -4054,22 +4096,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_packages", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.get_version", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVersion", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListPackages" + "shortName": "GetVersion" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" + "type": "google.cloud.artifactregistry_v1.types.GetVersionRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -4085,22 +4127,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesAsyncPager", - "shortName": "list_packages" + "resultType": "google.cloud.artifactregistry_v1.types.Version", + "shortName": "get_version" }, - "description": "Sample for ListPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_packages_async.py", + "description": "Sample for GetVersion", + "file": "artifactregistry_v1_generated_artifact_registry_get_version_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVersion_async", "segments": [ { - "end": 52, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 50, "start": 27, "type": "SHORT" }, @@ -4110,22 +4152,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_packages_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_version_async.py" }, { "canonical": true, @@ -4134,22 +4176,22 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_packages", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.get_version", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.GetVersion", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListPackages" + "shortName": "GetVersion" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" + "type": "google.cloud.artifactregistry_v1.types.GetVersionRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -4165,22 +4207,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesPager", - "shortName": "list_packages" + "resultType": "google.cloud.artifactregistry_v1.types.Version", + "shortName": "get_version" }, - "description": "Sample for ListPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_packages_sync.py", + "description": "Sample for GetVersion", + "file": "artifactregistry_v1_generated_artifact_registry_get_version_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_GetVersion_sync", "segments": [ { - "end": 52, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 50, "start": 27, "type": "SHORT" }, @@ -4190,22 +4232,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_packages_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_get_version_sync.py" }, { "canonical": true, @@ -4215,23 +4257,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_python_packages", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.import_apt_artifacts", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPythonPackages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportAptArtifacts", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListPythonPackages" + "shortName": "ImportAptArtifacts" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest" }, { "name": "retry", @@ -4246,22 +4284,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesAsyncPager", - "shortName": "list_python_packages" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "import_apt_artifacts" }, - "description": "Sample for ListPythonPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py", + "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_ListPythonPackages_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportAptArtifacts_async", "segments": [ { - "end": 52, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 54, "start": 27, "type": "SHORT" }, @@ -4271,22 +4309,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_python_packages_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_async.py" }, { "canonical": true, @@ -4295,23 +4333,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_python_packages", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.import_apt_artifacts", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPythonPackages", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportAptArtifacts", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListPythonPackages" + "shortName": "ImportAptArtifacts" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.artifactregistry_v1.types.ImportAptArtifactsRequest" }, { "name": "retry", @@ -4326,22 +4360,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesPager", - "shortName": "list_python_packages" + "resultType": "google.api_core.operation.Operation", + "shortName": "import_apt_artifacts" }, - "description": "Sample for ListPythonPackages", - "file": "artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py", + "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_ListPythonPackages_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportAptArtifacts_sync", "segments": [ { - "end": 52, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 54, "start": 27, "type": "SHORT" }, @@ -4351,22 +4385,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_python_packages_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_import_apt_artifacts_sync.py" }, { "canonical": true, @@ -4376,23 +4410,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_repositories", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.import_yum_artifacts", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRepositories", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportYumArtifacts", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListRepositories" + "shortName": "ImportYumArtifacts" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListRepositoriesRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest" }, { "name": "retry", @@ -4407,22 +4437,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListRepositoriesAsyncPager", - "shortName": "list_repositories" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "import_yum_artifacts" }, - "description": "Sample for ListRepositories", - "file": "artifactregistry_v1_generated_artifact_registry_list_repositories_async.py", + "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_ListRepositories_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportYumArtifacts_async", "segments": [ { - "end": 52, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 54, "start": 27, "type": "SHORT" }, @@ -4432,22 +4462,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_repositories_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_async.py" }, { "canonical": true, @@ -4456,23 +4486,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_repositories", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.import_yum_artifacts", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRepositories", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ImportYumArtifacts", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListRepositories" + "shortName": "ImportYumArtifacts" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListRepositoriesRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.cloud.artifactregistry_v1.types.ImportYumArtifactsRequest" }, { "name": "retry", @@ -4487,22 +4513,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListRepositoriesPager", - "shortName": "list_repositories" + "resultType": "google.api_core.operation.Operation", + "shortName": "import_yum_artifacts" }, - "description": "Sample for ListRepositories", - "file": "artifactregistry_v1_generated_artifact_registry_list_repositories_sync.py", + "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_ListRepositories_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ImportYumArtifacts_sync", "segments": [ { - "end": 52, + "end": 54, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 54, "start": 27, "type": "SHORT" }, @@ -4512,22 +4538,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 51, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 55, + "start": 52, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_list_repositories_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_import_yum_artifacts_sync.py" }, { "canonical": true, @@ -4537,19 +4563,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_tags", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_attachments", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListTags", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListAttachments", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListTags" + "shortName": "ListAttachments" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListTagsRequest" + "type": "google.cloud.artifactregistry_v1.types.ListAttachmentsRequest" }, { "name": "parent", @@ -4568,22 +4594,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsAsyncPager", - "shortName": "list_tags" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListAttachmentsAsyncPager", + "shortName": "list_attachments" }, - "description": "Sample for ListTags", - "file": "artifactregistry_v1_generated_artifact_registry_list_tags_async.py", + "description": "Sample for ListAttachments", + "file": "artifactregistry_v1_generated_artifact_registry_list_attachments_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListTags_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListAttachments_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -4593,22 +4619,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_tags_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_attachments_async.py" }, { "canonical": true, @@ -4617,19 +4643,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_tags", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_attachments", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListTags", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListAttachments", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListTags" + "shortName": "ListAttachments" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListTagsRequest" + "type": "google.cloud.artifactregistry_v1.types.ListAttachmentsRequest" }, { "name": "parent", @@ -4648,22 +4674,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsPager", - "shortName": "list_tags" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListAttachmentsPager", + "shortName": "list_attachments" }, - "description": "Sample for ListTags", - "file": "artifactregistry_v1_generated_artifact_registry_list_tags_sync.py", + "description": "Sample for ListAttachments", + "file": "artifactregistry_v1_generated_artifact_registry_list_attachments_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListTags_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListAttachments_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -4673,22 +4699,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_tags_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_attachments_sync.py" }, { "canonical": true, @@ -4698,19 +4724,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_versions", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_docker_images", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListVersions", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListDockerImages", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListVersions" + "shortName": "ListDockerImages" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListVersionsRequest" + "type": "google.cloud.artifactregistry_v1.types.ListDockerImagesRequest" }, { "name": "parent", @@ -4729,22 +4755,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListVersionsAsyncPager", - "shortName": "list_versions" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesAsyncPager", + "shortName": "list_docker_images" }, - "description": "Sample for ListVersions", - "file": "artifactregistry_v1_generated_artifact_registry_list_versions_async.py", + "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_ListVersions_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListDockerImages_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -4754,22 +4780,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_versions_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_docker_images_async.py" }, { "canonical": true, @@ -4778,19 +4804,19 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_versions", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_docker_images", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListVersions", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListDockerImages", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "ListVersions" + "shortName": "ListDockerImages" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.ListVersionsRequest" + "type": "google.cloud.artifactregistry_v1.types.ListDockerImagesRequest" }, { "name": "parent", @@ -4809,22 +4835,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListVersionsPager", - "shortName": "list_versions" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesPager", + "shortName": "list_docker_images" }, - "description": "Sample for ListVersions", - "file": "artifactregistry_v1_generated_artifact_registry_list_versions_sync.py", + "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_ListVersions_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListDockerImages_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -4834,22 +4860,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_versions_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_docker_images_sync.py" }, { "canonical": true, @@ -4859,19 +4885,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.set_iam_policy", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_files", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.SetIamPolicy", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListFiles", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "SetIamPolicy" + "shortName": "ListFiles" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + "type": "google.cloud.artifactregistry_v1.types.ListFilesRequest" + }, + { + "name": "parent", + "type": "str" }, { "name": "retry", @@ -4886,14 +4916,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "set_iam_policy" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesAsyncPager", + "shortName": "list_files" }, - "description": "Sample for SetIamPolicy", - "file": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py", + "description": "Sample for ListFiles", + "file": "artifactregistry_v1_generated_artifact_registry_list_files_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_SetIamPolicy_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListFiles_async", "segments": [ { "end": 52, @@ -4906,27 +4936,27 @@ "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 46, - "start": 42, + "end": 45, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { "end": 53, - "start": 50, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_list_files_async.py" }, { "canonical": true, @@ -4935,19 +4965,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.set_iam_policy", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_files", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.SetIamPolicy", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListFiles", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "SetIamPolicy" + "shortName": "ListFiles" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + "type": "google.cloud.artifactregistry_v1.types.ListFilesRequest" + }, + { + "name": "parent", + "type": "str" }, { "name": "retry", @@ -4962,14 +4996,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "set_iam_policy" + "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesPager", + "shortName": "list_files" }, - "description": "Sample for SetIamPolicy", - "file": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py", + "description": "Sample for ListFiles", + "file": "artifactregistry_v1_generated_artifact_registry_list_files_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_SetIamPolicy_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListFiles_sync", "segments": [ { "end": 52, @@ -4982,27 +5016,2128 @@ "type": "SHORT" }, { - "end": 41, - "start": 39, + "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_list_maven_artifacts_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_npm_packages", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListNpmPackages", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListNpmPackages" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest" + }, + { + "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.ListNpmPackagesAsyncPager", + "shortName": "list_npm_packages" + }, + "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_ListNpmPackages_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_npm_packages_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_npm_packages", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListNpmPackages", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListNpmPackages" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListNpmPackagesRequest" + }, + { + "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.ListNpmPackagesPager", + "shortName": "list_npm_packages" + }, + "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_ListNpmPackages_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_npm_packages_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_packages", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListPackages" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" + }, + { + "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.ListPackagesAsyncPager", + "shortName": "list_packages" + }, + "description": "Sample for ListPackages", + "file": "artifactregistry_v1_generated_artifact_registry_list_packages_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_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_packages_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_packages", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPackages", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListPackages" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListPackagesRequest" + }, + { + "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.ListPackagesPager", + "shortName": "list_packages" + }, + "description": "Sample for ListPackages", + "file": "artifactregistry_v1_generated_artifact_registry_list_packages_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListPackages_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_packages_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_python_packages", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPythonPackages", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListPythonPackages" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest" + }, + { + "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.ListPythonPackagesAsyncPager", + "shortName": "list_python_packages" + }, + "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_ListPythonPackages_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_python_packages_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_python_packages", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListPythonPackages", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListPythonPackages" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListPythonPackagesRequest" + }, + { + "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.ListPythonPackagesPager", + "shortName": "list_python_packages" + }, + "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_ListPythonPackages_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_python_packages_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_repositories", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRepositories", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListRepositories" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListRepositoriesRequest" + }, + { + "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.ListRepositoriesAsyncPager", + "shortName": "list_repositories" + }, + "description": "Sample for ListRepositories", + "file": "artifactregistry_v1_generated_artifact_registry_list_repositories_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListRepositories_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_repositories_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_repositories", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRepositories", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListRepositories" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListRepositoriesRequest" + }, + { + "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.ListRepositoriesPager", + "shortName": "list_repositories" + }, + "description": "Sample for ListRepositories", + "file": "artifactregistry_v1_generated_artifact_registry_list_repositories_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListRepositories_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_repositories_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_rules", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRules", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListRules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListRulesRequest" + }, + { + "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.ListRulesAsyncPager", + "shortName": "list_rules" + }, + "description": "Sample for ListRules", + "file": "artifactregistry_v1_generated_artifact_registry_list_rules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListRules_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_rules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_rules", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListRules", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListRules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListRulesRequest" + }, + { + "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.ListRulesPager", + "shortName": "list_rules" + }, + "description": "Sample for ListRules", + "file": "artifactregistry_v1_generated_artifact_registry_list_rules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListRules_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_rules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_tags", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListTags", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListTags" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListTagsRequest" + }, + { + "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.ListTagsAsyncPager", + "shortName": "list_tags" + }, + "description": "Sample for ListTags", + "file": "artifactregistry_v1_generated_artifact_registry_list_tags_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListTags_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "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": 52, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_tags_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_tags", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListTags", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListTags" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListTagsRequest" + }, + { + "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.ListTagsPager", + "shortName": "list_tags" + }, + "description": "Sample for ListTags", + "file": "artifactregistry_v1_generated_artifact_registry_list_tags_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListTags_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "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": 52, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_tags_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.list_versions", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListVersions", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListVersions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListVersionsRequest" + }, + { + "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.ListVersionsAsyncPager", + "shortName": "list_versions" + }, + "description": "Sample for ListVersions", + "file": "artifactregistry_v1_generated_artifact_registry_list_versions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListVersions_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "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": 52, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_versions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.list_versions", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.ListVersions", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "ListVersions" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.ListVersionsRequest" + }, + { + "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.ListVersionsPager", + "shortName": "list_versions" + }, + "description": "Sample for ListVersions", + "file": "artifactregistry_v1_generated_artifact_registry_list_versions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_ListVersions_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "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": 52, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_list_versions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.set_iam_policy", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.SetIamPolicy", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_SetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.set_iam_policy", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.SetIamPolicy", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_SetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.test_iam_permissions", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.TestIamPermissions", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_TestIamPermissions_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.test_iam_permissions", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.TestIamPermissions", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_TestIamPermissions_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_file", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateFile", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "UpdateFile" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.UpdateFileRequest" + }, + { + "name": "file", + "type": "google.cloud.artifactregistry_v1.types.File" + }, + { + "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.File", + "shortName": "update_file" + }, + "description": "Sample for UpdateFile", + "file": "artifactregistry_v1_generated_artifact_registry_update_file_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateFile_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_file_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_file", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateFile", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "UpdateFile" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.UpdateFileRequest" + }, + { + "name": "file", + "type": "google.cloud.artifactregistry_v1.types.File" + }, + { + "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.File", + "shortName": "update_file" + }, + "description": "Sample for UpdateFile", + "file": "artifactregistry_v1_generated_artifact_registry_update_file_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateFile_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_file_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_package", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdatePackage", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "UpdatePackage" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.UpdatePackageRequest" + }, + { + "name": "package", + "type": "google.cloud.artifactregistry_v1.types.Package" + }, + { + "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.Package", + "shortName": "update_package" + }, + "description": "Sample for UpdatePackage", + "file": "artifactregistry_v1_generated_artifact_registry_update_package_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdatePackage_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_package_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_package", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdatePackage", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "UpdatePackage" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.UpdatePackageRequest" + }, + { + "name": "package", + "type": "google.cloud.artifactregistry_v1.types.Package" + }, + { + "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.Package", + "shortName": "update_package" + }, + "description": "Sample for UpdatePackage", + "file": "artifactregistry_v1_generated_artifact_registry_update_package_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdatePackage_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_package_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", + "shortName": "ArtifactRegistryAsyncClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_project_settings", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateProjectSettings", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "UpdateProjectSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest" + }, + { + "name": "project_settings", + "type": "google.cloud.artifactregistry_v1.types.ProjectSettings" + }, + { + "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.ProjectSettings", + "shortName": "update_project_settings" + }, + "description": "Sample for UpdateProjectSettings", + "file": "artifactregistry_v1_generated_artifact_registry_update_project_settings_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateProjectSettings_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_project_settings_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", + "shortName": "ArtifactRegistryClient" + }, + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_project_settings", + "method": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateProjectSettings", + "service": { + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "shortName": "ArtifactRegistry" + }, + "shortName": "UpdateProjectSettings" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest" + }, + { + "name": "project_settings", + "type": "google.cloud.artifactregistry_v1.types.ProjectSettings" + }, + { + "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.ProjectSettings", + "shortName": "update_project_settings" + }, + "description": "Sample for UpdateProjectSettings", + "file": "artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateProjectSettings_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 46, - "start": 42, + "end": 44, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_set_iam_policy_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py" }, { "canonical": true, @@ -5012,19 +7147,27 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.test_iam_permissions", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.TestIamPermissions", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "TestIamPermissions" + "shortName": "UpdateRepository" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateRepositoryRequest" + }, + { + "name": "repository", + "type": "google.cloud.artifactregistry_v1.types.Repository" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5039,47 +7182,47 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", - "shortName": "test_iam_permissions" + "resultType": "google.cloud.artifactregistry_v1.types.Repository", + "shortName": "update_repository" }, - "description": "Sample for TestIamPermissions", - "file": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py", + "description": "Sample for UpdateRepository", + "file": "artifactregistry_v1_generated_artifact_registry_update_repository_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_TestIamPermissions_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRepository_async", "segments": [ { - "end": 53, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 50, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 47, - "start": 42, + "end": 44, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_repository_async.py" }, { "canonical": true, @@ -5088,19 +7231,27 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.test_iam_permissions", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_repository", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.TestIamPermissions", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRepository", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "TestIamPermissions" + "shortName": "UpdateRepository" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateRepositoryRequest" + }, + { + "name": "repository", + "type": "google.cloud.artifactregistry_v1.types.Repository" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -5115,47 +7266,47 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", - "shortName": "test_iam_permissions" + "resultType": "google.cloud.artifactregistry_v1.types.Repository", + "shortName": "update_repository" }, - "description": "Sample for TestIamPermissions", - "file": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py", + "description": "Sample for UpdateRepository", + "file": "artifactregistry_v1_generated_artifact_registry_update_repository_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_TestIamPermissions_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRepository_sync", "segments": [ { - "end": 53, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 50, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 47, - "start": 42, + "end": 44, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 51, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_test_iam_permissions_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_repository_sync.py" }, { "canonical": true, @@ -5165,23 +7316,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_project_settings", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_rule", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateProjectSettings", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRule", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "UpdateProjectSettings" + "shortName": "UpdateRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateRuleRequest" }, { - "name": "project_settings", - "type": "google.cloud.artifactregistry_v1.types.ProjectSettings" + "name": "rule", + "type": "google.cloud.artifactregistry_v1.types.Rule" }, { "name": "update_mask", @@ -5200,14 +7351,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", - "shortName": "update_project_settings" + "resultType": "google.cloud.artifactregistry_v1.types.Rule", + "shortName": "update_rule" }, - "description": "Sample for UpdateProjectSettings", - "file": "artifactregistry_v1_generated_artifact_registry_update_project_settings_async.py", + "description": "Sample for UpdateRule", + "file": "artifactregistry_v1_generated_artifact_registry_update_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateProjectSettings_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRule_async", "segments": [ { "end": 50, @@ -5240,7 +7391,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_update_project_settings_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_rule_async.py" }, { "canonical": true, @@ -5249,23 +7400,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_project_settings", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_rule", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateProjectSettings", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRule", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "UpdateProjectSettings" + "shortName": "UpdateRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateProjectSettingsRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateRuleRequest" }, { - "name": "project_settings", - "type": "google.cloud.artifactregistry_v1.types.ProjectSettings" + "name": "rule", + "type": "google.cloud.artifactregistry_v1.types.Rule" }, { "name": "update_mask", @@ -5284,14 +7435,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", - "shortName": "update_project_settings" + "resultType": "google.cloud.artifactregistry_v1.types.Rule", + "shortName": "update_rule" }, - "description": "Sample for UpdateProjectSettings", - "file": "artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py", + "description": "Sample for UpdateRule", + "file": "artifactregistry_v1_generated_artifact_registry_update_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateProjectSettings_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRule_sync", "segments": [ { "end": 50, @@ -5324,7 +7475,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_update_project_settings_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_rule_sync.py" }, { "canonical": true, @@ -5334,23 +7485,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "UpdateRepository" + "shortName": "UpdateTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateRepositoryRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateTagRequest" }, { - "name": "repository", - "type": "google.cloud.artifactregistry_v1.types.Repository" + "name": "tag", + "type": "google.cloud.artifactregistry_v1.types.Tag" }, { "name": "update_mask", @@ -5369,14 +7520,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Repository", - "shortName": "update_repository" + "resultType": "google.cloud.artifactregistry_v1.types.Tag", + "shortName": "update_tag" }, - "description": "Sample for UpdateRepository", - "file": "artifactregistry_v1_generated_artifact_registry_update_repository_async.py", + "description": "Sample for UpdateTag", + "file": "artifactregistry_v1_generated_artifact_registry_update_tag_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRepository_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateTag_async", "segments": [ { "end": 50, @@ -5409,7 +7560,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_update_repository_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_tag_async.py" }, { "canonical": true, @@ -5418,23 +7569,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_repository", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_tag", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateRepository", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateTag", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "UpdateRepository" + "shortName": "UpdateTag" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateRepositoryRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateTagRequest" }, { - "name": "repository", - "type": "google.cloud.artifactregistry_v1.types.Repository" + "name": "tag", + "type": "google.cloud.artifactregistry_v1.types.Tag" }, { "name": "update_mask", @@ -5453,14 +7604,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Repository", - "shortName": "update_repository" + "resultType": "google.cloud.artifactregistry_v1.types.Tag", + "shortName": "update_tag" }, - "description": "Sample for UpdateRepository", - "file": "artifactregistry_v1_generated_artifact_registry_update_repository_sync.py", + "description": "Sample for UpdateTag", + "file": "artifactregistry_v1_generated_artifact_registry_update_tag_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateRepository_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateTag_sync", "segments": [ { "end": 50, @@ -5493,7 +7644,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_update_repository_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_tag_sync.py" }, { "canonical": true, @@ -5503,23 +7654,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_vpcsc_config", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVPCSCConfig", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "UpdateTag" + "shortName": "UpdateVPCSCConfig" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateTagRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateVPCSCConfigRequest" }, { - "name": "tag", - "type": "google.cloud.artifactregistry_v1.types.Tag" + "name": "vpcsc_config", + "type": "google.cloud.artifactregistry_v1.types.VPCSCConfig" }, { "name": "update_mask", @@ -5538,14 +7689,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "update_tag" + "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", + "shortName": "update_vpcsc_config" }, - "description": "Sample for UpdateTag", - "file": "artifactregistry_v1_generated_artifact_registry_update_tag_async.py", + "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_UpdateTag_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_async", "segments": [ { "end": 50, @@ -5578,7 +7729,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_update_tag_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py" }, { "canonical": true, @@ -5587,23 +7738,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_tag", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_vpcsc_config", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateTag", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVPCSCConfig", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "UpdateTag" + "shortName": "UpdateVPCSCConfig" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateTagRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateVPCSCConfigRequest" }, { - "name": "tag", - "type": "google.cloud.artifactregistry_v1.types.Tag" + "name": "vpcsc_config", + "type": "google.cloud.artifactregistry_v1.types.VPCSCConfig" }, { "name": "update_mask", @@ -5622,14 +7773,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.Tag", - "shortName": "update_tag" + "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", + "shortName": "update_vpcsc_config" }, - "description": "Sample for UpdateTag", - "file": "artifactregistry_v1_generated_artifact_registry_update_tag_sync.py", + "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_UpdateTag_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_sync", "segments": [ { "end": 50, @@ -5662,7 +7813,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_update_tag_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py" }, { "canonical": true, @@ -5672,23 +7823,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient", "shortName": "ArtifactRegistryAsyncClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_vpcsc_config", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryAsyncClient.update_version", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVPCSCConfig", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVersion", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "UpdateVPCSCConfig" + "shortName": "UpdateVersion" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateVPCSCConfigRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateVersionRequest" }, { - "name": "vpcsc_config", - "type": "google.cloud.artifactregistry_v1.types.VPCSCConfig" + "name": "version", + "type": "google.cloud.artifactregistry_v1.types.Version" }, { "name": "update_mask", @@ -5707,14 +7858,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", - "shortName": "update_vpcsc_config" + "resultType": "google.cloud.artifactregistry_v1.types.Version", + "shortName": "update_version" }, - "description": "Sample for UpdateVPCSCConfig", - "file": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py", + "description": "Sample for UpdateVersion", + "file": "artifactregistry_v1_generated_artifact_registry_update_version_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_async", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVersion_async", "segments": [ { "end": 50, @@ -5747,7 +7898,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_async.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_version_async.py" }, { "canonical": true, @@ -5756,23 +7907,23 @@ "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient", "shortName": "ArtifactRegistryClient" }, - "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_vpcsc_config", + "fullName": "google.cloud.artifactregistry_v1.ArtifactRegistryClient.update_version", "method": { - "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVPCSCConfig", + "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry.UpdateVersion", "service": { "fullName": "google.devtools.artifactregistry.v1.ArtifactRegistry", "shortName": "ArtifactRegistry" }, - "shortName": "UpdateVPCSCConfig" + "shortName": "UpdateVersion" }, "parameters": [ { "name": "request", - "type": "google.cloud.artifactregistry_v1.types.UpdateVPCSCConfigRequest" + "type": "google.cloud.artifactregistry_v1.types.UpdateVersionRequest" }, { - "name": "vpcsc_config", - "type": "google.cloud.artifactregistry_v1.types.VPCSCConfig" + "name": "version", + "type": "google.cloud.artifactregistry_v1.types.Version" }, { "name": "update_mask", @@ -5791,14 +7942,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", - "shortName": "update_vpcsc_config" + "resultType": "google.cloud.artifactregistry_v1.types.Version", + "shortName": "update_version" }, - "description": "Sample for UpdateVPCSCConfig", - "file": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py", + "description": "Sample for UpdateVersion", + "file": "artifactregistry_v1_generated_artifact_registry_update_version_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVPCSCConfig_sync", + "regionTag": "artifactregistry_v1_generated_ArtifactRegistry_UpdateVersion_sync", "segments": [ { "end": 50, @@ -5831,7 +7982,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "artifactregistry_v1_generated_artifact_registry_update_vpcsc_config_sync.py" + "title": "artifactregistry_v1_generated_artifact_registry_update_version_sync.py" } ] } diff --git a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json index 8f243dc2f395..c22cba2a0008 100644 --- a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json +++ b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-artifact-registry", - "version": "1.12.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-artifact-registry/scripts/fixup_artifactregistry_v1_keywords.py b/packages/google-cloud-artifact-registry/scripts/fixup_artifactregistry_v1_keywords.py index 6316b6b72949..35798fee7dc3 100644 --- a/packages/google-cloud-artifact-registry/scripts/fixup_artifactregistry_v1_keywords.py +++ b/packages/google-cloud-artifact-registry/scripts/fixup_artifactregistry_v1_keywords.py @@ -40,12 +40,18 @@ class artifactregistryCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'batch_delete_versions': ('names', 'parent', 'validate_only', ), + 'create_attachment': ('parent', 'attachment_id', 'attachment', ), 'create_repository': ('parent', 'repository_id', 'repository', ), + 'create_rule': ('parent', 'rule_id', 'rule', ), 'create_tag': ('parent', 'tag_id', 'tag', ), + 'delete_attachment': ('name', ), + 'delete_file': ('name', ), 'delete_package': ('name', ), 'delete_repository': ('name', ), + 'delete_rule': ('name', ), 'delete_tag': ('name', ), 'delete_version': ('name', 'force', ), + 'get_attachment': ('name', ), 'get_docker_image': ('name', ), 'get_file': ('name', ), 'get_iam_policy': ('resource', 'options', ), @@ -55,25 +61,32 @@ class artifactregistryCallTransformer(cst.CSTTransformer): 'get_project_settings': ('name', ), 'get_python_package': ('name', ), 'get_repository': ('name', ), + 'get_rule': ('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_attachments': ('parent', 'filter', '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_packages': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), 'list_python_packages': ('parent', 'page_size', 'page_token', ), - 'list_repositories': ('parent', 'page_size', 'page_token', ), + 'list_repositories': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_rules': ('parent', 'page_size', 'page_token', ), 'list_tags': ('parent', 'filter', 'page_size', 'page_token', ), - 'list_versions': ('parent', 'page_size', 'page_token', 'view', 'order_by', ), + 'list_versions': ('parent', 'page_size', 'page_token', 'view', 'order_by', 'filter', ), 'set_iam_policy': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions': ('resource', 'permissions', ), + 'update_file': ('file', 'update_mask', ), + 'update_package': ('package', 'update_mask', ), 'update_project_settings': ('project_settings', 'update_mask', ), 'update_repository': ('repository', 'update_mask', ), + 'update_rule': ('rule', 'update_mask', ), 'update_tag': ('tag', 'update_mask', ), + 'update_version': ('version', 'update_mask', ), 'update_vpcsc_config': ('vpcsc_config', 'update_mask', ), } diff --git a/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py b/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py index 2532d0579d76..bbb41a4d2ed8 100644 --- a/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py +++ b/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py @@ -78,14 +78,23 @@ pagers, 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 apt_artifact, artifact +from google.cloud.artifactregistry_v1.types import attachment +from google.cloud.artifactregistry_v1.types import attachment as gda_attachment +from google.cloud.artifactregistry_v1.types import file +from google.cloud.artifactregistry_v1.types import file as gda_file +from google.cloud.artifactregistry_v1.types import package +from google.cloud.artifactregistry_v1.types import package as gda_package 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 rule +from google.cloud.artifactregistry_v1.types import rule as gda_rule 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 +from google.cloud.artifactregistry_v1.types import version as gda_version from google.cloud.artifactregistry_v1.types import vpcsc_config from google.cloud.artifactregistry_v1.types import yum_artifact @@ -5334,6 +5343,8 @@ def test_list_repositories_non_empty_request_with_auto_populated_field(): request = repository.ListRepositoriesRequest( parent="parent_value", page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5349,6 +5360,8 @@ def test_list_repositories_non_empty_request_with_auto_populated_field(): assert args[0] == repository.ListRepositoriesRequest( parent="parent_value", page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) @@ -5854,6 +5867,8 @@ def test_get_repository(request_type, transport: str = "grpc"): size_bytes=1089, satisfies_pzs=True, cleanup_policy_dry_run=True, + disallow_unspecified_mode=True, + satisfies_pzi=True, ) response = client.get_repository(request) @@ -5873,6 +5888,8 @@ def test_get_repository(request_type, transport: str = "grpc"): assert response.size_bytes == 1089 assert response.satisfies_pzs is True assert response.cleanup_policy_dry_run is True + assert response.disallow_unspecified_mode is True + assert response.satisfies_pzi is True def test_get_repository_non_empty_request_with_auto_populated_field(): @@ -6006,6 +6023,8 @@ async def test_get_repository_async( size_bytes=1089, satisfies_pzs=True, cleanup_policy_dry_run=True, + disallow_unspecified_mode=True, + satisfies_pzi=True, ) ) response = await client.get_repository(request) @@ -6026,6 +6045,8 @@ async def test_get_repository_async( assert response.size_bytes == 1089 assert response.satisfies_pzs is True assert response.cleanup_policy_dry_run is True + assert response.disallow_unspecified_mode is True + assert response.satisfies_pzi is True @pytest.mark.asyncio @@ -6596,6 +6617,8 @@ def test_update_repository(request_type, transport: str = "grpc"): size_bytes=1089, satisfies_pzs=True, cleanup_policy_dry_run=True, + disallow_unspecified_mode=True, + satisfies_pzi=True, ) response = client.update_repository(request) @@ -6615,6 +6638,8 @@ def test_update_repository(request_type, transport: str = "grpc"): assert response.size_bytes == 1089 assert response.satisfies_pzs is True assert response.cleanup_policy_dry_run is True + assert response.disallow_unspecified_mode is True + assert response.satisfies_pzi is True def test_update_repository_non_empty_request_with_auto_populated_field(): @@ -6750,6 +6775,8 @@ async def test_update_repository_async( size_bytes=1089, satisfies_pzs=True, cleanup_policy_dry_run=True, + disallow_unspecified_mode=True, + satisfies_pzi=True, ) ) response = await client.update_repository(request) @@ -6770,6 +6797,8 @@ async def test_update_repository_async( assert response.size_bytes == 1089 assert response.satisfies_pzs is True assert response.cleanup_policy_dry_run is True + assert response.disallow_unspecified_mode is True + assert response.satisfies_pzi is True @pytest.mark.asyncio @@ -7355,6 +7384,8 @@ def test_list_packages_non_empty_request_with_auto_populated_field(): request = package.ListPackagesRequest( parent="parent_value", page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7368,6 +7399,8 @@ def test_list_packages_non_empty_request_with_auto_populated_field(): assert args[0] == package.ListPackagesRequest( parent="parent_value", page_token="page_token_value", + filter="filter_value", + order_by="order_by_value", ) @@ -8525,6 +8558,7 @@ def test_list_versions_non_empty_request_with_auto_populated_field(): parent="parent_value", page_token="page_token_value", order_by="order_by_value", + filter="filter_value", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8539,6 +8573,7 @@ def test_list_versions_non_empty_request_with_auto_populated_field(): parent="parent_value", page_token="page_token_value", order_by="order_by_value", + filter="filter_value", ) @@ -10001,6 +10036,335 @@ async def test_batch_delete_versions_flattened_error_async(): ) +@pytest.mark.parametrize( + "request_type", + [ + gda_version.UpdateVersionRequest, + dict, + ], +) +def test_update_version(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_version), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gda_version.Version( + name="name_value", + description="description_value", + ) + response = client.update_version(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gda_version.UpdateVersionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gda_version.Version) + assert response.name == "name_value" + assert response.description == "description_value" + + +def test_update_version_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = gda_version.UpdateVersionRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_version), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_version(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gda_version.UpdateVersionRequest() + + +def test_update_version_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_version in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_version] = mock_rpc + request = {} + client.update_version(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_version(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_version_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.update_version + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_version + ] = mock_rpc + + request = {} + await client.update_version(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.update_version(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_version_async( + transport: str = "grpc_asyncio", request_type=gda_version.UpdateVersionRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + 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_version), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_version.Version( + name="name_value", + description="description_value", + ) + ) + response = await client.update_version(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gda_version.UpdateVersionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gda_version.Version) + assert response.name == "name_value" + assert response.description == "description_value" + + +@pytest.mark.asyncio +async def test_update_version_async_from_dict(): + await test_update_version_async(request_type=dict) + + +def test_update_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 = gda_version.UpdateVersionRequest() + + request.version.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_version), "__call__") as call: + call.return_value = gda_version.Version() + client.update_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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "version.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_version_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # 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_version.UpdateVersionRequest() + + request.version.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_version), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_version.Version()) + await client.update_version(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", + "version.name=name_value", + ) in kw["metadata"] + + +def test_update_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.update_version), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gda_version.Version() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_version( + version=gda_version.Version(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].version + mock_val = gda_version.Version(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_version_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_version( + gda_version.UpdateVersionRequest(), + version=gda_version.Version(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_version_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_version), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gda_version.Version() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_version.Version()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_version( + version=gda_version.Version(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].version + mock_val = gda_version.Version(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_version_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_version( + gda_version.UpdateVersionRequest(), + version=gda_version.Version(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + @pytest.mark.parametrize( "request_type", [ @@ -10850,11 +11214,11 @@ async def test_get_file_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - tag.ListTagsRequest, + file.DeleteFileRequest, dict, ], ) -def test_list_tags(request_type, transport: str = "grpc"): +def test_delete_file(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -10865,25 +11229,22 @@ 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.delete_file), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse( - next_page_token="next_page_token_value", - ) - response = client.list_tags(request) + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = tag.ListTagsRequest() + request = file.DeleteFileRequest() assert args[0] == request # 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, future.Future) -def test_list_tags_non_empty_request_with_auto_populated_field(): +def test_delete_file_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -10894,28 +11255,24 @@ def test_list_tags_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = tag.ListTagsRequest( - parent="parent_value", - filter="filter_value", - page_token="page_token_value", + request = file.DeleteFileRequest( + name="name_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: + with mock.patch.object(type(client.transport.delete_file), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.list_tags(request=request) + client.delete_file(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.ListTagsRequest( - parent="parent_value", - filter="filter_value", - page_token="page_token_value", + assert args[0] == file.DeleteFileRequest( + name="name_value", ) -def test_list_tags_use_cached_wrapped_rpc(): +def test_delete_file_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -10929,21 +11286,26 @@ def test_list_tags_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_tags in client._transport._wrapped_methods + assert client._transport.delete_file in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_tags] = mock_rpc + client._transport._wrapped_methods[client._transport.delete_file] = mock_rpc request = {} - client.list_tags(request) + client.delete_file(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_tags(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_file(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -10951,7 +11313,9 @@ def test_list_tags_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_list_tags_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_delete_file_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -10966,7 +11330,7 @@ async def test_list_tags_async_use_cached_wrapped_rpc(transport: str = "grpc_asy # Ensure method has been cached assert ( - client._client._transport.list_tags + client._client._transport.delete_file in client._client._transport._wrapped_methods ) @@ -10974,16 +11338,21 @@ async def test_list_tags_async_use_cached_wrapped_rpc(transport: str = "grpc_asy mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.list_tags + client._client._transport.delete_file ] = mock_rpc request = {} - await client.list_tags(request) + await client.delete_file(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.list_tags(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_file(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -10991,8 +11360,8 @@ async def test_list_tags_async_use_cached_wrapped_rpc(transport: str = "grpc_asy @pytest.mark.asyncio -async def test_list_tags_async( - transport: str = "grpc_asyncio", request_type=tag.ListTagsRequest +async def test_delete_file_async( + transport: str = "grpc_asyncio", request_type=file.DeleteFileRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -11004,46 +11373,43 @@ 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.delete_file), "__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", - ) + operations_pb2.Operation(name="operations/spam") ) - response = await client.list_tags(request) + response = await client.delete_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = tag.ListTagsRequest() + request = file.DeleteFileRequest() assert args[0] == request # 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, future.Future) @pytest.mark.asyncio -async def test_list_tags_async_from_dict(): - await test_list_tags_async(request_type=dict) +async def test_delete_file_async_from_dict(): + await test_delete_file_async(request_type=dict) -def test_list_tags_field_headers(): +def test_delete_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 = tag.ListTagsRequest() + request = file.DeleteFileRequest() - 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_tags), "__call__") as call: - call.return_value = tag.ListTagsResponse() - client.list_tags(request) + with mock.patch.object(type(client.transport.delete_file), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -11054,28 +11420,28 @@ def test_list_tags_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_tags_field_headers_async(): +async def test_delete_file_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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 = file.DeleteFileRequest() - 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_tags), "__call__") as call: + with mock.patch.object(type(client.transport.delete_file), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - tag.ListTagsResponse() + operations_pb2.Operation(name="operations/op") ) - await client.list_tags(request) + await client.delete_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -11086,35 +11452,35 @@ async def test_list_tags_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_tags_flattened(): +def test_delete_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.list_tags), "__call__") as call: + with mock.patch.object(type(client.transport.delete_file), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse() + 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_tags( - parent="parent_value", + client.delete_file( + 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_tags_flattened_error(): +def test_delete_file_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -11122,43 +11488,43 @@ 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", + client.delete_file( + file.DeleteFileRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_list_tags_flattened_async(): +async def test_delete_file_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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.delete_file), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.ListTagsResponse() + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - tag.ListTagsResponse() + 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_tags( - parent="parent_value", + response = await client.delete_file( + 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_tags_flattened_error_async(): +async def test_delete_file_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -11166,214 +11532,20 @@ async def test_list_tags_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_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, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_tags(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - 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=async_anonymous_credentials(), - ) - - # 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={}, - ) - 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) - - -@pytest.mark.asyncio -async def test_list_tags_async_pages(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # 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, + await client.delete_file( + file.DeleteFileRequest(), + name="name_value", ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_tags(request={}) - ).pages: - 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_file.UpdateFileRequest, dict, ], ) -def test_get_tag(request_type, transport: str = "grpc"): +def test_update_file(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -11384,27 +11556,29 @@ 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_file), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.Tag( + call.return_value = gda_file.File( name="name_value", - version="version_value", + size_bytes=1089, + owner="owner_value", ) - response = client.get_tag(request) + response = client.update_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = tag.GetTagRequest() + request = gda_file.UpdateFileRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) + assert isinstance(response, gda_file.File) assert response.name == "name_value" - assert response.version == "version_value" + assert response.size_bytes == 1089 + assert response.owner == "owner_value" -def test_get_tag_non_empty_request_with_auto_populated_field(): +def test_update_file_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -11415,24 +11589,20 @@ def test_get_tag_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = tag.GetTagRequest( - name="name_value", - ) + request = gda_file.UpdateFileRequest() # 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_file), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_tag(request=request) + client.update_file(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.GetTagRequest( - name="name_value", - ) + assert args[0] == gda_file.UpdateFileRequest() -def test_get_tag_use_cached_wrapped_rpc(): +def test_update_file_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -11446,21 +11616,21 @@ def test_get_tag_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_tag in client._transport._wrapped_methods + assert client._transport.update_file in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_tag] = mock_rpc + client._transport._wrapped_methods[client._transport.update_file] = mock_rpc request = {} - client.get_tag(request) + client.update_file(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_tag(request) + client.update_file(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -11468,7 +11638,9 @@ def test_get_tag_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_update_file_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -11483,7 +11655,7 @@ async def test_get_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_async # Ensure method has been cached assert ( - client._client._transport.get_tag + client._client._transport.update_file in client._client._transport._wrapped_methods ) @@ -11491,16 +11663,16 @@ async def test_get_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_async mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_tag + client._client._transport.update_file ] = mock_rpc request = {} - await client.get_tag(request) + await client.update_file(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_tag(request) + await client.update_file(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -11508,8 +11680,8 @@ async def test_get_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_async @pytest.mark.asyncio -async def test_get_tag_async( - transport: str = "grpc_asyncio", request_type=tag.GetTagRequest +async def test_update_file_async( + transport: str = "grpc_asyncio", request_type=gda_file.UpdateFileRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -11521,48 +11693,50 @@ 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_file), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - tag.Tag( + gda_file.File( name="name_value", - version="version_value", + size_bytes=1089, + owner="owner_value", ) ) - response = await client.get_tag(request) + response = await client.update_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = tag.GetTagRequest() + request = gda_file.UpdateFileRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) + assert isinstance(response, gda_file.File) assert response.name == "name_value" - assert response.version == "version_value" + assert response.size_bytes == 1089 + assert response.owner == "owner_value" @pytest.mark.asyncio -async def test_get_tag_async_from_dict(): - await test_get_tag_async(request_type=dict) +async def test_update_file_async_from_dict(): + await test_update_file_async(request_type=dict) -def test_get_tag_field_headers(): +def test_update_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 = tag.GetTagRequest() + request = gda_file.UpdateFileRequest() - request.name = "name_value" + request.file.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_file), "__call__") as call: + call.return_value = gda_file.File() + client.update_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -11573,26 +11747,26 @@ def test_get_tag_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "file.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_tag_field_headers_async(): +async def test_update_file_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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_file.UpdateFileRequest() - request.name = "name_value" + request.file.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_file), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_file.File()) + await client.update_file(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -11603,35 +11777,39 @@ async def test_get_tag_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "file.name=name_value", ) in kw["metadata"] -def test_get_tag_flattened(): +def test_update_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.get_tag), "__call__") as call: + with mock.patch.object(type(client.transport.update_file), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.Tag() + call.return_value = gda_file.File() # 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_file( + file=gda_file.File(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].file + mock_val = gda_file.File(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_file_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -11639,41 +11817,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_file( + gda_file.UpdateFileRequest(), + file=gda_file.File(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_file_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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_file), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = tag.Tag() + call.return_value = gda_file.File() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tag.Tag()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_file.File()) # 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_file( + file=gda_file.File(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].file + mock_val = gda_file.File(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_file_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -11681,20 +11864,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_file( + gda_file.UpdateFileRequest(), + file=gda_file.File(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.parametrize( "request_type", [ - gda_tag.CreateTagRequest, + tag.ListTagsRequest, dict, ], ) -def test_create_tag(request_type, transport: str = "grpc"): +def test_list_tags(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -11705,27 +11889,25 @@ 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.list_tags), "__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 = tag.ListTagsResponse( + next_page_token="next_page_token_value", ) - response = client.create_tag(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] - request = gda_tag.CreateTagRequest() + request = tag.ListTagsRequest() assert args[0] == request # 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, pagers.ListTagsPager) + assert response.next_page_token == "next_page_token_value" -def test_create_tag_non_empty_request_with_auto_populated_field(): +def test_list_tags_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -11736,26 +11918,28 @@ def test_create_tag_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = gda_tag.CreateTagRequest( + request = tag.ListTagsRequest( parent="parent_value", - tag_id="tag_id_value", + filter="filter_value", + page_token="page_token_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: + with mock.patch.object(type(client.transport.list_tags), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.create_tag(request=request) + client.list_tags(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.CreateTagRequest( + assert args[0] == tag.ListTagsRequest( parent="parent_value", - tag_id="tag_id_value", + filter="filter_value", + page_token="page_token_value", ) -def test_create_tag_use_cached_wrapped_rpc(): +def test_list_tags_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -11769,21 +11953,21 @@ def test_create_tag_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.create_tag in client._transport._wrapped_methods + assert client._transport.list_tags in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.create_tag] = mock_rpc + client._transport._wrapped_methods[client._transport.list_tags] = mock_rpc request = {} - client.create_tag(request) + client.list_tags(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.create_tag(request) + client.list_tags(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -11791,7 +11975,7 @@ def test_create_tag_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_create_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_list_tags_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -11806,7 +11990,7 @@ async def test_create_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as # Ensure method has been cached assert ( - client._client._transport.create_tag + client._client._transport.list_tags in client._client._transport._wrapped_methods ) @@ -11814,16 +11998,16 @@ async def test_create_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.create_tag + client._client._transport.list_tags ] = mock_rpc request = {} - await client.create_tag(request) + await client.list_tags(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.create_tag(request) + await client.list_tags(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -11831,8 +12015,8 @@ async def test_create_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_create_tag_async( - transport: str = "grpc_asyncio", request_type=gda_tag.CreateTagRequest +async def test_list_tags_async( + transport: str = "grpc_asyncio", request_type=tag.ListTagsRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -11844,48 +12028,46 @@ 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.list_tags), "__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", + tag.ListTagsResponse( + next_page_token="next_page_token_value", ) ) - response = await client.create_tag(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] - request = gda_tag.CreateTagRequest() + request = tag.ListTagsRequest() assert args[0] == request # 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, pagers.ListTagsAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_create_tag_async_from_dict(): - await test_create_tag_async(request_type=dict) +async def test_list_tags_async_from_dict(): + await test_list_tags_async(request_type=dict) -def test_create_tag_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 = gda_tag.CreateTagRequest() + 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.create_tag), "__call__") as call: - call.return_value = gda_tag.Tag() - client.create_tag(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 @@ -11901,21 +12083,23 @@ def test_create_tag_field_headers(): @pytest.mark.asyncio -async def test_create_tag_field_headers_async(): +async def test_list_tags_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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.ListTagsRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.create_tag), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) - await client.create_tag(request) + 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) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -11930,21 +12114,19 @@ async def test_create_tag_field_headers_async(): ) in kw["metadata"] -def test_create_tag_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.create_tag), "__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 = gda_tag.Tag() + call.return_value = tag.ListTagsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_tag( + client.list_tags( 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 @@ -11954,15 +12136,9 @@ def test_create_tag_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_create_tag_flattened_error(): +def test_list_tags_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -11970,32 +12146,30 @@ 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(), + client.list_tags( + tag.ListTagsRequest(), parent="parent_value", - tag=gda_tag.Tag(name="name_value"), - tag_id="tag_id_value", ) @pytest.mark.asyncio -async def test_create_tag_flattened_async(): +async def test_list_tags_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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.list_tags), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag() + call.return_value = tag.ListTagsResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) + 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.create_tag( + response = await client.list_tags( 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 @@ -12005,16 +12179,10 @@ async def test_create_tag_flattened_async(): 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_create_tag_flattened_error_async(): +async def test_list_tags_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -12022,22 +12190,214 @@ 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(), + await client.list_tags( + tag.ListTagsRequest(), parent="parent_value", - tag=gda_tag.Tag(name="name_value"), - tag_id="tag_id_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, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_tags(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + 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=async_anonymous_credentials(), + ) + + # 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={}, + ) + 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) + + +@pytest.mark.asyncio +async def test_list_tags_async_pages(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # 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, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_tags(request={}) + ).pages: + 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", [ - gda_tag.UpdateTagRequest, + tag.GetTagRequest, dict, ], ) -def test_update_tag(request_type, transport: str = "grpc"): +def test_get_tag(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -12048,27 +12408,27 @@ 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.get_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag( + call.return_value = tag.Tag( name="name_value", version="version_value", ) - response = client.update_tag(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] - request = gda_tag.UpdateTagRequest() + request = tag.GetTagRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, gda_tag.Tag) + assert isinstance(response, tag.Tag) assert response.name == "name_value" assert response.version == "version_value" -def test_update_tag_non_empty_request_with_auto_populated_field(): +def test_get_tag_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -12079,20 +12439,24 @@ def test_update_tag_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = gda_tag.UpdateTagRequest() + request = tag.GetTagRequest( + name="name_value", + ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_tag), "__call__") as call: + with mock.patch.object(type(client.transport.get_tag), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.update_tag(request=request) + client.get_tag(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_tag.UpdateTagRequest() + assert args[0] == tag.GetTagRequest( + name="name_value", + ) -def test_update_tag_use_cached_wrapped_rpc(): +def test_get_tag_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -12106,21 +12470,21 @@ def test_update_tag_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.update_tag in client._transport._wrapped_methods + assert client._transport.get_tag in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.update_tag] = mock_rpc + client._transport._wrapped_methods[client._transport.get_tag] = mock_rpc request = {} - client.update_tag(request) + client.get_tag(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_tag(request) + client.get_tag(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -12128,7 +12492,7 @@ def test_update_tag_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_update_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_get_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -12143,7 +12507,7 @@ async def test_update_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as # Ensure method has been cached assert ( - client._client._transport.update_tag + client._client._transport.get_tag in client._client._transport._wrapped_methods ) @@ -12151,16 +12515,16 @@ async def test_update_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.update_tag + client._client._transport.get_tag ] = mock_rpc request = {} - await client.update_tag(request) + await client.get_tag(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.update_tag(request) + await client.get_tag(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -12168,8 +12532,8 @@ async def test_update_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_update_tag_async( - transport: str = "grpc_asyncio", request_type=gda_tag.UpdateTagRequest +async def test_get_tag_async( + transport: str = "grpc_asyncio", request_type=tag.GetTagRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -12181,48 +12545,48 @@ 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.get_tag), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gda_tag.Tag( + tag.Tag( name="name_value", version="version_value", ) ) - response = await client.update_tag(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] - request = gda_tag.UpdateTagRequest() + request = tag.GetTagRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, gda_tag.Tag) + assert isinstance(response, tag.Tag) assert response.name == "name_value" assert response.version == "version_value" @pytest.mark.asyncio -async def test_update_tag_async_from_dict(): - await test_update_tag_async(request_type=dict) +async def test_get_tag_async_from_dict(): + await test_get_tag_async(request_type=dict) -def test_update_tag_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 = gda_tag.UpdateTagRequest() + request = tag.GetTagRequest() - request.tag.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.update_tag), "__call__") as call: - call.return_value = gda_tag.Tag() - client.update_tag(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 @@ -12233,26 +12597,26 @@ def test_update_tag_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "tag.name=name_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_tag_field_headers_async(): +async def test_get_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = gda_tag.UpdateTagRequest() + request = tag.GetTagRequest() - request.tag.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.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.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) @@ -12263,39 +12627,35 @@ async def test_update_tag_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "tag.name=name_value", + "name=name_value", ) in kw["metadata"] -def test_update_tag_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.update_tag), "__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 = gda_tag.Tag() + call.return_value = 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"]), + client.get_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].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"]) + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_update_tag_flattened_error(): +def test_get_tag_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -12303,46 +12663,41 @@ def test_update_tag_flattened_error(): # 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"]), + client.get_tag( + tag.GetTagRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_update_tag_flattened_async(): +async def test_get_tag_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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.get_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_tag.Tag() + call.return_value = tag.Tag() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_tag.Tag()) + 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.update_tag( - tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + response = await client.get_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].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"]) + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_update_tag_flattened_error_async(): +async def test_get_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -12350,21 +12705,20 @@ async def test_update_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.update_tag( - gda_tag.UpdateTagRequest(), - tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + await client.get_tag( + tag.GetTagRequest(), + name="name_value", ) @pytest.mark.parametrize( "request_type", [ - tag.DeleteTagRequest, + gda_tag.CreateTagRequest, dict, ], ) -def test_delete_tag(request_type, transport: str = "grpc"): +def test_create_tag(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -12375,22 +12729,27 @@ 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.create_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_tag(request) + call.return_value = gda_tag.Tag( + name="name_value", + version="version_value", + ) + response = client.create_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = tag.DeleteTagRequest() + request = gda_tag.CreateTagRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, gda_tag.Tag) + assert response.name == "name_value" + assert response.version == "version_value" -def test_delete_tag_non_empty_request_with_auto_populated_field(): +def test_create_tag_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -12401,24 +12760,26 @@ def test_delete_tag_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = tag.DeleteTagRequest( - name="name_value", + request = gda_tag.CreateTagRequest( + parent="parent_value", + tag_id="tag_id_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: + with mock.patch.object(type(client.transport.create_tag), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.delete_tag(request=request) + client.create_tag(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tag.DeleteTagRequest( - name="name_value", + assert args[0] == gda_tag.CreateTagRequest( + parent="parent_value", + tag_id="tag_id_value", ) -def test_delete_tag_use_cached_wrapped_rpc(): +def test_create_tag_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -12432,21 +12793,21 @@ def test_delete_tag_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_tag in client._transport._wrapped_methods + assert client._transport.create_tag in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_tag] = mock_rpc + client._transport._wrapped_methods[client._transport.create_tag] = mock_rpc request = {} - client.delete_tag(request) + client.create_tag(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.delete_tag(request) + client.create_tag(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -12454,7 +12815,7 @@ def test_delete_tag_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_delete_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): +async def test_create_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -12469,7 +12830,7 @@ async def test_delete_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as # Ensure method has been cached assert ( - client._client._transport.delete_tag + client._client._transport.create_tag in client._client._transport._wrapped_methods ) @@ -12477,16 +12838,16 @@ async def test_delete_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.delete_tag + client._client._transport.create_tag ] = mock_rpc request = {} - await client.delete_tag(request) + await client.create_tag(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.delete_tag(request) + await client.create_tag(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -12494,8 +12855,8 @@ async def test_delete_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_delete_tag_async( - transport: str = "grpc_asyncio", request_type=tag.DeleteTagRequest +async def test_create_tag_async( + transport: str = "grpc_asyncio", request_type=gda_tag.CreateTagRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -12507,41 +12868,48 @@ 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.create_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_tag(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_tag.Tag( + name="name_value", + version="version_value", + ) + ) + response = await client.create_tag(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = tag.DeleteTagRequest() + request = gda_tag.CreateTagRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, gda_tag.Tag) + assert response.name == "name_value" + assert response.version == "version_value" @pytest.mark.asyncio -async def test_delete_tag_async_from_dict(): - await test_delete_tag_async(request_type=dict) +async def test_create_tag_async_from_dict(): + await test_create_tag_async(request_type=dict) -def test_delete_tag_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.DeleteTagRequest() + request = gda_tag.CreateTagRequest() - 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.delete_tag), "__call__") as call: - call.return_value = None - client.delete_tag(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 @@ -12552,26 +12920,26 @@ def test_delete_tag_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_delete_tag_field_headers_async(): +async def test_create_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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 = gda_tag.CreateTagRequest() - 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.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.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) @@ -12582,35 +12950,43 @@ async def test_delete_tag_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "parent=parent_value", ) in kw["metadata"] -def test_delete_tag_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.delete_tag), "__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 = None + 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.delete_tag( - name="name_value", + 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 # 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 + 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_delete_tag_flattened_error(): +def test_create_tag_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -12618,41 +12994,51 @@ def test_delete_tag_flattened_error(): # 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", + client.create_tag( + gda_tag.CreateTagRequest(), + parent="parent_value", + tag=gda_tag.Tag(name="name_value"), + tag_id="tag_id_value", ) @pytest.mark.asyncio -async def test_delete_tag_flattened_async(): +async def test_create_tag_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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.create_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = None + call.return_value = gda_tag.Tag() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + 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.delete_tag( - name="name_value", + response = await 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 # 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 + 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_delete_tag_flattened_error_async(): +async def test_create_tag_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -12660,20 +13046,22 @@ async def test_delete_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.delete_tag( - tag.DeleteTagRequest(), - name="name_value", + await client.create_tag( + gda_tag.CreateTagRequest(), + parent="parent_value", + tag=gda_tag.Tag(name="name_value"), + tag_id="tag_id_value", ) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.SetIamPolicyRequest, + gda_tag.UpdateTagRequest, dict, ], ) -def test_set_iam_policy(request_type, transport: str = "grpc"): +def test_update_tag(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -12684,27 +13072,27 @@ 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.update_tag), "__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 = gda_tag.Tag( + name="name_value", + version="version_value", ) - response = client.set_iam_policy(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] - request = iam_policy_pb2.SetIamPolicyRequest() + request = gda_tag.UpdateTagRequest() assert args[0] == request # 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, gda_tag.Tag) + assert response.name == "name_value" + assert response.version == "version_value" -def test_set_iam_policy_non_empty_request_with_auto_populated_field(): +def test_update_tag_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -12715,24 +13103,20 @@ def test_set_iam_policy_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) + request = gda_tag.UpdateTagRequest() # 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.update_tag), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.set_iam_policy(request=request) + client.update_tag(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", - ) + assert args[0] == gda_tag.UpdateTagRequest() -def test_set_iam_policy_use_cached_wrapped_rpc(): +def test_update_tag_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -12746,21 +13130,21 @@ def test_set_iam_policy_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.set_iam_policy in client._transport._wrapped_methods + assert client._transport.update_tag in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.set_iam_policy] = mock_rpc + client._transport._wrapped_methods[client._transport.update_tag] = mock_rpc request = {} - client.set_iam_policy(request) + client.update_tag(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.set_iam_policy(request) + client.update_tag(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -12768,9 +13152,7 @@ def test_set_iam_policy_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_set_iam_policy_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): +async def test_update_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -12785,7 +13167,7 @@ async def test_set_iam_policy_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.set_iam_policy + client._client._transport.update_tag in client._client._transport._wrapped_methods ) @@ -12793,16 +13175,16 @@ async def test_set_iam_policy_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.set_iam_policy + client._client._transport.update_tag ] = mock_rpc request = {} - await client.set_iam_policy(request) + await client.update_tag(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.set_iam_policy(request) + await client.update_tag(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -12810,8 +13192,8 @@ async def test_set_iam_policy_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_set_iam_policy_async( - transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest +async def test_update_tag_async( + transport: str = "grpc_asyncio", request_type=gda_tag.UpdateTagRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -12823,48 +13205,48 @@ 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.update_tag), "__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", + gda_tag.Tag( + name="name_value", + version="version_value", ) ) - response = await client.set_iam_policy(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] - request = iam_policy_pb2.SetIamPolicyRequest() + request = gda_tag.UpdateTagRequest() assert args[0] == request # 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, gda_tag.Tag) + assert response.name == "name_value" + assert response.version == "version_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_update_tag_async_from_dict(): + await test_update_tag_async(request_type=dict) -def test_set_iam_policy_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 = iam_policy_pb2.SetIamPolicyRequest() + request = gda_tag.UpdateTagRequest() - request.resource = "resource_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.set_iam_policy), "__call__") as call: - call.return_value = policy_pb2.Policy() - client.set_iam_policy(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 @@ -12875,26 +13257,26 @@ def test_set_iam_policy_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "tag.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_set_iam_policy_field_headers_async(): +async def test_update_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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 = gda_tag.UpdateTagRequest() - request.resource = "resource_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.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.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) @@ -12905,36 +13287,108 @@ async def test_set_iam_policy_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "tag.name=name_value", ) in kw["metadata"] -def test_set_iam_policy_from_dict_foreign(): +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.set_iam_policy), "__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 = 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.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=async_anonymous_credentials(), + ) + + # 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 + + +@pytest.mark.asyncio +async def test_update_tag_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # 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"]), ) - call.assert_called() @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.GetIamPolicyRequest, + tag.DeleteTagRequest, dict, ], ) -def test_get_iam_policy(request_type, transport: str = "grpc"): +def test_delete_tag(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -12945,27 +13399,22 @@ 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.delete_tag), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) - response = client.get_iam_policy(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] - request = iam_policy_pb2.GetIamPolicyRequest() + request = tag.DeleteTagRequest() assert args[0] == request # 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 response is None -def test_get_iam_policy_non_empty_request_with_auto_populated_field(): +def test_delete_tag_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -12976,24 +13425,24 @@ def test_get_iam_policy_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", + request = tag.DeleteTagRequest( + 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: + with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_iam_policy(request=request) + client.delete_tag(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", + assert args[0] == tag.DeleteTagRequest( + name="name_value", ) -def test_get_iam_policy_use_cached_wrapped_rpc(): +def test_delete_tag_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -13007,21 +13456,21 @@ def test_get_iam_policy_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_iam_policy in client._transport._wrapped_methods + assert client._transport.delete_tag in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_iam_policy] = mock_rpc + client._transport._wrapped_methods[client._transport.delete_tag] = mock_rpc request = {} - client.get_iam_policy(request) + client.delete_tag(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_iam_policy(request) + client.delete_tag(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -13029,9 +13478,7 @@ def test_get_iam_policy_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_iam_policy_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): +async def test_delete_tag_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -13046,7 +13493,7 @@ async def test_get_iam_policy_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.get_iam_policy + client._client._transport.delete_tag in client._client._transport._wrapped_methods ) @@ -13054,16 +13501,16 @@ async def test_get_iam_policy_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_iam_policy + client._client._transport.delete_tag ] = mock_rpc request = {} - await client.get_iam_policy(request) + await client.delete_tag(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_iam_policy(request) + await client.delete_tag(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -13071,8 +13518,8 @@ async def test_get_iam_policy_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_iam_policy_async( - transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest +async def test_delete_tag_async( + transport: str = "grpc_asyncio", request_type=tag.DeleteTagRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -13084,48 +13531,41 @@ 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.delete_tag), "__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", - ) - ) - response = await client.get_iam_policy(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] - request = iam_policy_pb2.GetIamPolicyRequest() + request = tag.DeleteTagRequest() assert args[0] == request # 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 response is None @pytest.mark.asyncio -async def test_get_iam_policy_async_from_dict(): - await test_get_iam_policy_async(request_type=dict) +async def test_delete_tag_async_from_dict(): + await test_delete_tag_async(request_type=dict) -def test_get_iam_policy_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 = iam_policy_pb2.GetIamPolicyRequest() + request = tag.DeleteTagRequest() - 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.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 @@ -13136,26 +13576,26 @@ 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_delete_tag_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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 = tag.DeleteTagRequest() - 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.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) @@ -13166,35 +13606,98 @@ 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_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.get_iam_policy), "__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 = policy_pb2.Policy() - response = client.get_iam_policy( - request={ - "resource": "resource_value", - "options": options_pb2.GetPolicyOptions(requested_policy_version=2598), - } + 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(): + 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=async_anonymous_credentials(), + ) + + # 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.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=async_anonymous_credentials(), + ) + + # 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.assert_called() @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.TestIamPermissionsRequest, + gda_rule.CreateRuleRequest, dict, ], ) -def test_test_iam_permissions(request_type, transport: str = "grpc"): +def test_create_rule(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -13205,27 +13708,31 @@ def test_test_iam_permissions(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.test_iam_permissions), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], + call.return_value = gda_rule.Rule( + name="name_value", + action=gda_rule.Rule.Action.ALLOW, + operation=gda_rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", ) - response = client.test_iam_permissions(request) + response = client.create_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.TestIamPermissionsRequest() + request = gda_rule.CreateRuleRequest() assert args[0] == request # 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, gda_rule.Rule) + assert response.name == "name_value" + assert response.action == gda_rule.Rule.Action.ALLOW + assert response.operation == gda_rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" -def test_test_iam_permissions_non_empty_request_with_auto_populated_field(): +def test_create_rule_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -13236,26 +13743,26 @@ def test_test_iam_permissions_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", + request = gda_rule.CreateRuleRequest( + parent="parent_value", + rule_id="rule_id_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_rule), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.test_iam_permissions(request=request) + client.create_rule(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", + assert args[0] == gda_rule.CreateRuleRequest( + parent="parent_value", + rule_id="rule_id_value", ) -def test_test_iam_permissions_use_cached_wrapped_rpc(): +def test_create_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -13269,25 +13776,21 @@ def test_test_iam_permissions_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.test_iam_permissions in client._transport._wrapped_methods - ) + assert client._transport.create_rule in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.test_iam_permissions - ] = mock_rpc + client._transport._wrapped_methods[client._transport.create_rule] = mock_rpc request = {} - client.test_iam_permissions(request) + client.create_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.test_iam_permissions(request) + client.create_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -13295,7 +13798,7 @@ def test_test_iam_permissions_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_test_iam_permissions_async_use_cached_wrapped_rpc( +async def test_create_rule_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -13312,7 +13815,7 @@ async def test_test_iam_permissions_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.test_iam_permissions + client._client._transport.create_rule in client._client._transport._wrapped_methods ) @@ -13320,16 +13823,16 @@ async def test_test_iam_permissions_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.test_iam_permissions + client._client._transport.create_rule ] = mock_rpc request = {} - await client.test_iam_permissions(request) + await client.create_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.test_iam_permissions(request) + await client.create_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -13337,9 +13840,8 @@ async def test_test_iam_permissions_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_test_iam_permissions_async( - transport: str = "grpc_asyncio", - request_type=iam_policy_pb2.TestIamPermissionsRequest, +async def test_create_rule_async( + transport: str = "grpc_asyncio", request_type=gda_rule.CreateRuleRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -13351,50 +13853,52 @@ async def test_test_iam_permissions_async( request = request_type() # 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: + with mock.patch.object(type(client.transport.create_rule), "__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"], + gda_rule.Rule( + name="name_value", + action=gda_rule.Rule.Action.ALLOW, + operation=gda_rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", ) ) - response = await client.test_iam_permissions(request) + response = await client.create_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.TestIamPermissionsRequest() + request = gda_rule.CreateRuleRequest() assert args[0] == request # 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, gda_rule.Rule) + assert response.name == "name_value" + assert response.action == gda_rule.Rule.Action.ALLOW + assert response.operation == gda_rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" @pytest.mark.asyncio -async def test_test_iam_permissions_async_from_dict(): - await test_test_iam_permissions_async(request_type=dict) +async def test_create_rule_async_from_dict(): + await test_create_rule_async(request_type=dict) -def test_test_iam_permissions_field_headers(): +def test_create_rule_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 = gda_rule.CreateRuleRequest() - request.resource = "resource_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" - ) as call: - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() - client.test_iam_permissions(request) + with mock.patch.object(type(client.transport.create_rule), "__call__") as call: + call.return_value = gda_rule.Rule() + client.create_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -13405,30 +13909,26 @@ def test_test_iam_permissions_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_test_iam_permissions_field_headers_async(): +async def test_create_rule_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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 = gda_rule.CreateRuleRequest() - request.resource = "resource_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy_pb2.TestIamPermissionsResponse() - ) - await client.test_iam_permissions(request) + with mock.patch.object(type(client.transport.create_rule), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule()) + await client.create_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -13439,37 +13939,118 @@ async def test_test_iam_permissions_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "parent=parent_value", ) in kw["metadata"] -def test_test_iam_permissions_from_dict_foreign(): +def test_create_rule_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__" - ) as call: + with mock.patch.object(type(client.transport.create_rule), "__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 = gda_rule.Rule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_rule( + parent="parent_value", + rule=gda_rule.Rule(name="name_value"), + rule_id="rule_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].rule + mock_val = gda_rule.Rule(name="name_value") + assert arg == mock_val + arg = args[0].rule_id + mock_val = "rule_id_value" + assert arg == mock_val + + +def test_create_rule_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_rule( + gda_rule.CreateRuleRequest(), + parent="parent_value", + rule=gda_rule.Rule(name="name_value"), + rule_id="rule_id_value", + ) + + +@pytest.mark.asyncio +async def test_create_rule_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gda_rule.Rule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_rule( + parent="parent_value", + rule=gda_rule.Rule(name="name_value"), + rule_id="rule_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].rule + mock_val = gda_rule.Rule(name="name_value") + assert arg == mock_val + arg = args[0].rule_id + mock_val = "rule_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_rule_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_rule( + gda_rule.CreateRuleRequest(), + parent="parent_value", + rule=gda_rule.Rule(name="name_value"), + rule_id="rule_id_value", ) - call.assert_called() @pytest.mark.parametrize( "request_type", [ - settings.GetProjectSettingsRequest, + rule.ListRulesRequest, dict, ], ) -def test_get_project_settings(request_type, transport: str = "grpc"): +def test_list_rules(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -13480,32 +14061,25 @@ 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.list_rules), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings( - name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + call.return_value = rule.ListRulesResponse( + next_page_token="next_page_token_value", ) - response = client.get_project_settings(request) + response = client.list_rules(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = settings.GetProjectSettingsRequest() + request = rule.ListRulesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) - assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert isinstance(response, pagers.ListRulesPager) + assert response.next_page_token == "next_page_token_value" -def test_get_project_settings_non_empty_request_with_auto_populated_field(): +def test_list_rules_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -13516,26 +14090,26 @@ def test_get_project_settings_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = settings.GetProjectSettingsRequest( - name="name_value", + request = rule.ListRulesRequest( + parent="parent_value", + page_token="page_token_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.list_rules), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_project_settings(request=request) + client.list_rules(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == settings.GetProjectSettingsRequest( - name="name_value", + assert args[0] == rule.ListRulesRequest( + parent="parent_value", + page_token="page_token_value", ) -def test_get_project_settings_use_cached_wrapped_rpc(): +def test_list_rules_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -13549,25 +14123,21 @@ def test_get_project_settings_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.get_project_settings in client._transport._wrapped_methods - ) + assert client._transport.list_rules in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.get_project_settings - ] = mock_rpc + client._transport._wrapped_methods[client._transport.list_rules] = mock_rpc request = {} - client.get_project_settings(request) + client.list_rules(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_project_settings(request) + client.list_rules(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -13575,9 +14145,7 @@ def test_get_project_settings_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_project_settings_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): +async def test_list_rules_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -13592,7 +14160,7 @@ async def test_get_project_settings_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.get_project_settings + client._client._transport.list_rules in client._client._transport._wrapped_methods ) @@ -13600,16 +14168,16 @@ async def test_get_project_settings_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_project_settings + client._client._transport.list_rules ] = mock_rpc request = {} - await client.get_project_settings(request) + await client.list_rules(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_project_settings(request) + await client.list_rules(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -13617,8 +14185,8 @@ async def test_get_project_settings_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_project_settings_async( - transport: str = "grpc_asyncio", request_type=settings.GetProjectSettingsRequest +async def test_list_rules_async( + transport: str = "grpc_asyncio", request_type=rule.ListRulesRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -13630,55 +14198,46 @@ 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.list_rules), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings( - name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + rule.ListRulesResponse( + next_page_token="next_page_token_value", ) ) - response = await client.get_project_settings(request) + response = await client.list_rules(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = settings.GetProjectSettingsRequest() + request = rule.ListRulesRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) - assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert isinstance(response, pagers.ListRulesAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_get_project_settings_async_from_dict(): - await test_get_project_settings_async(request_type=dict) +async def test_list_rules_async_from_dict(): + await test_list_rules_async(request_type=dict) -def test_get_project_settings_field_headers(): +def test_list_rules_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 = rule.ListRulesRequest() - 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_project_settings), "__call__" - ) as call: - call.return_value = settings.ProjectSettings() - client.get_project_settings(request) + with mock.patch.object(type(client.transport.list_rules), "__call__") as call: + call.return_value = rule.ListRulesResponse() + client.list_rules(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -13689,30 +14248,28 @@ def test_get_project_settings_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_project_settings_field_headers_async(): +async def test_list_rules_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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 = rule.ListRulesRequest() - 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_project_settings), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_rules), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings() + rule.ListRulesResponse() ) - await client.get_project_settings(request) + await client.list_rules(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -13723,37 +14280,35 @@ async def test_get_project_settings_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_project_settings_flattened(): +def test_list_rules_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.list_rules), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings() + call.return_value = rule.ListRulesResponse() # 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", + client.list_rules( + 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_project_settings_flattened_error(): +def test_list_rules_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -13761,45 +14316,43 @@ 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(), - name="name_value", + client.list_rules( + rule.ListRulesRequest(), + parent="parent_value", ) @pytest.mark.asyncio -async def test_get_project_settings_flattened_async(): +async def test_list_rules_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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.list_rules), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings() + call.return_value = rule.ListRulesResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings() + rule.ListRulesResponse() ) # 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", + response = await client.list_rules( + 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_project_settings_flattened_error_async(): +async def test_list_rules_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -13807,20 +14360,214 @@ 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(), - name="name_value", + await client.list_rules( + rule.ListRulesRequest(), + parent="parent_value", + ) + + +def test_list_rules_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_rules), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + rule.Rule(), + ], + next_page_token="abc", + ), + rule.ListRulesResponse( + rules=[], + next_page_token="def", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + ], + next_page_token="ghi", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_rules(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, rule.Rule) for i in results) + + +def test_list_rules_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_rules), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + rule.Rule(), + ], + next_page_token="abc", + ), + rule.ListRulesResponse( + rules=[], + next_page_token="def", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + ], + next_page_token="ghi", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_rules(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_rules_async_pager(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_rules), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + rule.Rule(), + ], + next_page_token="abc", + ), + rule.ListRulesResponse( + rules=[], + next_page_token="def", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + ], + next_page_token="ghi", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_rules( + 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, rule.Rule) for i in responses) + + +@pytest.mark.asyncio +async def test_list_rules_async_pages(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_rules), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + rule.Rule(), + ], + next_page_token="abc", + ), + rule.ListRulesResponse( + rules=[], + next_page_token="def", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + ], + next_page_token="ghi", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + ], + ), + RuntimeError, ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_rules(request={}) + ).pages: + 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", [ - settings.UpdateProjectSettingsRequest, + rule.GetRuleRequest, dict, ], ) -def test_update_project_settings(request_type, transport: str = "grpc"): +def test_get_rule(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -13831,32 +14578,31 @@ def test_update_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.update_project_settings), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings( + call.return_value = rule.Rule( name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + action=rule.Rule.Action.ALLOW, + operation=rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", ) - response = client.update_project_settings(request) + response = client.get_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = settings.UpdateProjectSettingsRequest() + request = rule.GetRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) + assert isinstance(response, rule.Rule) assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert response.action == rule.Rule.Action.ALLOW + assert response.operation == rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" -def test_update_project_settings_non_empty_request_with_auto_populated_field(): +def test_get_rule_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -13867,22 +14613,24 @@ def test_update_project_settings_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = settings.UpdateProjectSettingsRequest() + request = rule.GetRuleRequest( + 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__" - ) as call: + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.update_project_settings(request=request) + client.get_rule(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == settings.UpdateProjectSettingsRequest() + assert args[0] == rule.GetRuleRequest( + name="name_value", + ) -def test_update_project_settings_use_cached_wrapped_rpc(): +def test_get_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -13896,26 +14644,21 @@ def test_update_project_settings_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.update_project_settings - in client._transport._wrapped_methods - ) + assert client._transport.get_rule in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.update_project_settings - ] = mock_rpc + client._transport._wrapped_methods[client._transport.get_rule] = mock_rpc request = {} - client.update_project_settings(request) + client.get_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_project_settings(request) + client.get_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -13923,9 +14666,7 @@ def test_update_project_settings_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_update_project_settings_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): +async def test_get_rule_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -13940,7 +14681,7 @@ async def test_update_project_settings_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.update_project_settings + client._client._transport.get_rule in client._client._transport._wrapped_methods ) @@ -13948,16 +14689,16 @@ async def test_update_project_settings_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.update_project_settings + client._client._transport.get_rule ] = mock_rpc request = {} - await client.update_project_settings(request) + await client.get_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.update_project_settings(request) + await client.get_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -13965,8 +14706,8 @@ async def test_update_project_settings_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_project_settings_async( - transport: str = "grpc_asyncio", request_type=settings.UpdateProjectSettingsRequest +async def test_get_rule_async( + transport: str = "grpc_asyncio", request_type=rule.GetRuleRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -13978,55 +14719,52 @@ async def test_update_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.update_project_settings), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings( + rule.Rule( name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + action=rule.Rule.Action.ALLOW, + operation=rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", ) ) - response = await client.update_project_settings(request) + response = await client.get_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = settings.UpdateProjectSettingsRequest() + request = rule.GetRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) + assert isinstance(response, rule.Rule) assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert response.action == rule.Rule.Action.ALLOW + assert response.operation == rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" @pytest.mark.asyncio -async def test_update_project_settings_async_from_dict(): - await test_update_project_settings_async(request_type=dict) +async def test_get_rule_async_from_dict(): + await test_get_rule_async(request_type=dict) -def test_update_project_settings_field_headers(): +def test_get_rule_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 = rule.GetRuleRequest() - request.project_settings.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_project_settings), "__call__" - ) as call: - call.return_value = settings.ProjectSettings() - client.update_project_settings(request) + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: + call.return_value = rule.Rule() + client.get_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -14037,30 +14775,26 @@ def test_update_project_settings_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "project_settings.name=name_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_project_settings_field_headers_async(): +async def test_get_rule_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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 = rule.GetRuleRequest() - request.project_settings.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_project_settings), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings() - ) - await client.update_project_settings(request) + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(rule.Rule()) + await client.get_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -14071,41 +14805,35 @@ async def test_update_project_settings_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "project_settings.name=name_value", + "name=name_value", ) in kw["metadata"] -def test_update_project_settings_flattened(): +def test_get_rule_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__" - ) as call: + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings() + call.return_value = rule.Rule() # 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"]), + client.get_rule( + 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].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"]) + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_update_project_settings_flattened_error(): +def test_get_rule_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -14113,50 +14841,41 @@ 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"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_rule( + rule.GetRuleRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_update_project_settings_flattened_async(): +async def test_get_rule_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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: + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = settings.ProjectSettings() + call.return_value = rule.Rule() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings() - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(rule.Rule()) # 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"]), + response = await client.get_rule( + 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].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"]) + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_update_project_settings_flattened_error_async(): +async def test_get_rule_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -14164,21 +14883,20 @@ 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"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + await client.get_rule( + rule.GetRuleRequest(), + name="name_value", ) @pytest.mark.parametrize( "request_type", [ - vpcsc_config.GetVPCSCConfigRequest, + gda_rule.UpdateRuleRequest, dict, ], ) -def test_get_vpcsc_config(request_type, transport: str = "grpc"): +def test_update_rule(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -14189,27 +14907,31 @@ def test_get_vpcsc_config(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_vpcsc_config), "__call__") as call: + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = vpcsc_config.VPCSCConfig( + call.return_value = gda_rule.Rule( name="name_value", - vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, + action=gda_rule.Rule.Action.ALLOW, + operation=gda_rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", ) - response = client.get_vpcsc_config(request) + response = client.update_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = vpcsc_config.GetVPCSCConfigRequest() + request = gda_rule.UpdateRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, vpcsc_config.VPCSCConfig) + assert isinstance(response, gda_rule.Rule) assert response.name == "name_value" - assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY + assert response.action == gda_rule.Rule.Action.ALLOW + assert response.operation == gda_rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" -def test_get_vpcsc_config_non_empty_request_with_auto_populated_field(): +def test_update_rule_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -14220,24 +14942,20 @@ def test_get_vpcsc_config_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = vpcsc_config.GetVPCSCConfigRequest( - name="name_value", - ) + request = gda_rule.UpdateRuleRequest() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_vpcsc_config(request=request) + client.update_rule(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vpcsc_config.GetVPCSCConfigRequest( - name="name_value", - ) + assert args[0] == gda_rule.UpdateRuleRequest() -def test_get_vpcsc_config_use_cached_wrapped_rpc(): +def test_update_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -14251,23 +14969,21 @@ def test_get_vpcsc_config_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_vpcsc_config in client._transport._wrapped_methods + assert client._transport.update_rule in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.get_vpcsc_config - ] = mock_rpc + client._transport._wrapped_methods[client._transport.update_rule] = mock_rpc request = {} - client.get_vpcsc_config(request) + client.update_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_vpcsc_config(request) + client.update_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14275,7 +14991,7 @@ def test_get_vpcsc_config_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_vpcsc_config_async_use_cached_wrapped_rpc( +async def test_update_rule_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -14292,7 +15008,7 @@ async def test_get_vpcsc_config_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.get_vpcsc_config + client._client._transport.update_rule in client._client._transport._wrapped_methods ) @@ -14300,16 +15016,16 @@ async def test_get_vpcsc_config_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_vpcsc_config + client._client._transport.update_rule ] = mock_rpc request = {} - await client.get_vpcsc_config(request) + await client.update_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_vpcsc_config(request) + await client.update_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14317,8 +15033,8 @@ async def test_get_vpcsc_config_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_vpcsc_config_async( - transport: str = "grpc_asyncio", request_type=vpcsc_config.GetVPCSCConfigRequest +async def test_update_rule_async( + transport: str = "grpc_asyncio", request_type=gda_rule.UpdateRuleRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -14330,48 +15046,52 @@ async def test_get_vpcsc_config_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - vpcsc_config.VPCSCConfig( + gda_rule.Rule( name="name_value", - vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, + action=gda_rule.Rule.Action.ALLOW, + operation=gda_rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", ) ) - response = await client.get_vpcsc_config(request) + response = await client.update_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = vpcsc_config.GetVPCSCConfigRequest() + request = gda_rule.UpdateRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, vpcsc_config.VPCSCConfig) + assert isinstance(response, gda_rule.Rule) assert response.name == "name_value" - assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY + assert response.action == gda_rule.Rule.Action.ALLOW + assert response.operation == gda_rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" @pytest.mark.asyncio -async def test_get_vpcsc_config_async_from_dict(): - await test_get_vpcsc_config_async(request_type=dict) +async def test_update_rule_async_from_dict(): + await test_update_rule_async(request_type=dict) -def test_get_vpcsc_config_field_headers(): +def test_update_rule_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 = vpcsc_config.GetVPCSCConfigRequest() + request = gda_rule.UpdateRuleRequest() - request.name = "name_value" + request.rule.name = "name_value" # Mock the actual call within the gRPC stub, and fake the 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) + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: + call.return_value = gda_rule.Rule() + client.update_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -14382,28 +15102,26 @@ def test_get_vpcsc_config_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "rule.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_vpcsc_config_field_headers_async(): +async def test_update_rule_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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 = vpcsc_config.GetVPCSCConfigRequest() + request = gda_rule.UpdateRuleRequest() - request.name = "name_value" + request.rule.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - vpcsc_config.VPCSCConfig() - ) - await client.get_vpcsc_config(request) + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule()) + await client.update_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -14414,35 +15132,39 @@ async def test_get_vpcsc_config_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "rule.name=name_value", ) in kw["metadata"] -def test_get_vpcsc_config_flattened(): +def test_update_rule_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_vpcsc_config), "__call__") as call: + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = vpcsc_config.VPCSCConfig() + call.return_value = gda_rule.Rule() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_vpcsc_config( - name="name_value", + client.update_rule( + rule=gda_rule.Rule(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].rule + mock_val = gda_rule.Rule(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_vpcsc_config_flattened_error(): +def test_update_rule_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -14450,43 +15172,46 @@ def test_get_vpcsc_config_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_vpcsc_config( - vpcsc_config.GetVPCSCConfigRequest(), - name="name_value", + client.update_rule( + gda_rule.UpdateRuleRequest(), + rule=gda_rule.Rule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio -async def test_get_vpcsc_config_flattened_async(): +async def test_update_rule_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = vpcsc_config.VPCSCConfig() + call.return_value = gda_rule.Rule() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - vpcsc_config.VPCSCConfig() - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_rule.Rule()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_vpcsc_config( - name="name_value", + response = await client.update_rule( + rule=gda_rule.Rule(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].rule + mock_val = gda_rule.Rule(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_vpcsc_config_flattened_error_async(): +async def test_update_rule_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -14494,20 +15219,21 @@ async def test_get_vpcsc_config_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_vpcsc_config( - vpcsc_config.GetVPCSCConfigRequest(), - name="name_value", + await client.update_rule( + gda_rule.UpdateRuleRequest(), + rule=gda_rule.Rule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.parametrize( "request_type", [ - gda_vpcsc_config.UpdateVPCSCConfigRequest, + rule.DeleteRuleRequest, dict, ], ) -def test_update_vpcsc_config(request_type, transport: str = "grpc"): +def test_delete_rule(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -14518,29 +15244,22 @@ def test_update_vpcsc_config(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_vpcsc_config), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_vpcsc_config.VPCSCConfig( - name="name_value", - vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) - response = client.update_vpcsc_config(request) + call.return_value = None + response = client.delete_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = gda_vpcsc_config.UpdateVPCSCConfigRequest() + request = rule.DeleteRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, gda_vpcsc_config.VPCSCConfig) - assert response.name == "name_value" - assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY + assert response is None -def test_update_vpcsc_config_non_empty_request_with_auto_populated_field(): +def test_delete_rule_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( @@ -14551,22 +15270,24 @@ def test_update_vpcsc_config_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = gda_vpcsc_config.UpdateVPCSCConfigRequest() + request = rule.DeleteRuleRequest( + name="name_value", + ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.update_vpcsc_config(request=request) + client.delete_rule(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gda_vpcsc_config.UpdateVPCSCConfigRequest() + assert args[0] == rule.DeleteRuleRequest( + name="name_value", + ) -def test_update_vpcsc_config_use_cached_wrapped_rpc(): +def test_delete_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -14580,25 +15301,21 @@ def test_update_vpcsc_config_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.update_vpcsc_config in client._transport._wrapped_methods - ) + assert client._transport.delete_rule in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.update_vpcsc_config - ] = mock_rpc + client._transport._wrapped_methods[client._transport.delete_rule] = mock_rpc request = {} - client.update_vpcsc_config(request) + client.delete_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_vpcsc_config(request) + client.delete_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14606,7 +15323,7 @@ def test_update_vpcsc_config_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_update_vpcsc_config_async_use_cached_wrapped_rpc( +async def test_delete_rule_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -14623,7 +15340,7 @@ async def test_update_vpcsc_config_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.update_vpcsc_config + client._client._transport.delete_rule in client._client._transport._wrapped_methods ) @@ -14631,16 +15348,16 @@ async def test_update_vpcsc_config_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.update_vpcsc_config + client._client._transport.delete_rule ] = mock_rpc request = {} - await client.update_vpcsc_config(request) + await client.delete_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.update_vpcsc_config(request) + await client.delete_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -14648,9 +15365,8 @@ async def test_update_vpcsc_config_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_vpcsc_config_async( - transport: str = "grpc_asyncio", - request_type=gda_vpcsc_config.UpdateVPCSCConfigRequest, +async def test_delete_rule_async( + transport: str = "grpc_asyncio", request_type=rule.DeleteRuleRequest ): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), @@ -14662,52 +15378,41 @@ async def test_update_vpcsc_config_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gda_vpcsc_config.VPCSCConfig( - name="name_value", - vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) - ) - response = await client.update_vpcsc_config(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = gda_vpcsc_config.UpdateVPCSCConfigRequest() + request = rule.DeleteRuleRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, gda_vpcsc_config.VPCSCConfig) - assert response.name == "name_value" - assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY + assert response is None @pytest.mark.asyncio -async def test_update_vpcsc_config_async_from_dict(): - await test_update_vpcsc_config_async(request_type=dict) +async def test_delete_rule_async_from_dict(): + await test_delete_rule_async(request_type=dict) -def test_update_vpcsc_config_field_headers(): +def test_delete_rule_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_vpcsc_config.UpdateVPCSCConfigRequest() + request = rule.DeleteRuleRequest() - request.vpcsc_config.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), "__call__" - ) as call: - call.return_value = gda_vpcsc_config.VPCSCConfig() - client.update_vpcsc_config(request) + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: + call.return_value = None + client.delete_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -14718,30 +15423,26 @@ def test_update_vpcsc_config_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "vpcsc_config.name=name_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_vpcsc_config_field_headers_async(): +async def test_delete_rule_field_headers_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # 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_vpcsc_config.UpdateVPCSCConfigRequest() + request = rule.DeleteRuleRequest() - request.vpcsc_config.name = "name_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gda_vpcsc_config.VPCSCConfig() - ) - await client.update_vpcsc_config(request) + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_rule(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -14752,41 +15453,35 @@ async def test_update_vpcsc_config_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "vpcsc_config.name=name_value", + "name=name_value", ) in kw["metadata"] -def test_update_vpcsc_config_flattened(): +def test_delete_rule_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_vpcsc_config), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_vpcsc_config.VPCSCConfig() + call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_vpcsc_config( - vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.delete_rule( + 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].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"]) + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_update_vpcsc_config_flattened_error(): +def test_delete_rule_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -14794,50 +15489,41 @@ def test_update_vpcsc_config_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - 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"]), + client.delete_rule( + rule.DeleteRuleRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_update_vpcsc_config_flattened_async(): +async def test_delete_rule_flattened_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = gda_vpcsc_config.VPCSCConfig() + call.return_value = None - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gda_vpcsc_config.VPCSCConfig() - ) + 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.update_vpcsc_config( - vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + response = await client.delete_rule( + 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].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"]) + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_update_vpcsc_config_flattened_error_async(): +async def test_delete_rule_flattened_error_async(): client = ArtifactRegistryAsyncClient( credentials=async_anonymous_credentials(), ) @@ -14845,20 +15531,85 @@ async def test_update_vpcsc_config_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_vpcsc_config( - gda_vpcsc_config.UpdateVPCSCConfigRequest(), - vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + await client.delete_rule( + rule.DeleteRuleRequest(), + name="name_value", ) -def test_list_docker_images_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) +def test_set_iam_policy(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.set_iam_policy), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + 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] + request = iam_policy_pb2.SetIamPolicyRequest() + assert args[0] == request + + # 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" + + +def test_set_iam_policy_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = iam_policy_pb2.SetIamPolicyRequest( + 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.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.set_iam_policy(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + +def test_set_iam_policy_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -14866,261 +15617,260 @@ def test_list_docker_images_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.list_docker_images in client._transport._wrapped_methods - ) + assert client._transport.set_iam_policy in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.list_docker_images - ] = mock_rpc - + client._transport._wrapped_methods[client._transport.set_iam_policy] = mock_rpc request = {} - client.list_docker_images(request) + client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_docker_images(request) + client.set_iam_policy(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_docker_images_rest_required_fields( - request_type=artifact.ListDockerImagesRequest, +@pytest.mark.asyncio +async def test_set_iam_policy_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ArtifactRegistryRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.set_iam_policy + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_docker_images._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.set_iam_policy + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.set_iam_policy(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_docker_images._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "order_by", - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) + await client.set_iam_policy(request) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_set_iam_policy_async( + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = artifact.ListDockerImagesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # 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() - response_value = Response() - response_value.status_code = 200 + # 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 = grpc_helpers_async.FakeUnaryUnaryCall( + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + ) + response = await client.set_iam_policy(request) - # Convert return value to protobuf type - return_value = artifact.ListDockerImagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = iam_policy_pb2.SetIamPolicyRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # 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" - response = client.list_docker_images(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_set_iam_policy_async_from_dict(): + await test_set_iam_policy_async(request_type=dict) -def test_list_docker_images_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_set_iam_policy_field_headers(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.list_docker_images._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "orderBy", - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = iam_policy_pb2.SetIamPolicyRequest() + request.resource = "resource_value" -def test_list_docker_images_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + # 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 http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListDockerImagesResponse() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.ListDockerImagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_set_iam_policy_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) - client.list_docker_images(**mock_args) + # 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() - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*}/dockerImages" - % client.transport._host, - args[1], - ) + 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) -def test_list_docker_images_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_docker_images( - artifact.ListDockerImagesRequest(), - parent="parent_value", - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] -def test_list_docker_images_rest_pager(transport: str = "rest"): +def test_set_iam_policy_from_dict_foreign(): client = ArtifactRegistryClient( 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.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() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - artifact.DockerImage(), - ], - next_page_token="abc", - ), - artifact.ListDockerImagesResponse( - docker_images=[], - next_page_token="def", - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - ], - next_page_token="ghi", - ), - artifact.ListDockerImagesResponse( - docker_images=[ - artifact.DockerImage(), - artifact.DockerImage(), - ], - ), + +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) +def test_get_iam_policy(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_iam_policy), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", ) - # Two responses for two calls - response = response + response + response = client.get_iam_policy(request) - # Wrap the values into proper Response objs - response = tuple(artifact.ListDockerImagesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = iam_policy_pb2.GetIamPolicyRequest() + assert args[0] == request - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } + # 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" - pager = client.list_docker_images(request=sample_request) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.DockerImage) for i in results) +def test_get_iam_policy_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) - pages = list(client.list_docker_images(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_iam_policy(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) -def test_get_docker_image_rest_use_cached_wrapped_rpc(): + +def test_get_iam_policy_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -15128,179 +15878,261 @@ def test_get_docker_image_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_docker_image in client._transport._wrapped_methods + assert client._transport.get_iam_policy in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.get_docker_image + client._transport._wrapped_methods[client._transport.get_iam_policy] = mock_rpc + request = {} + client.get_iam_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_iam_policy(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_iam_policy_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_iam_policy + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_iam_policy ] = mock_rpc request = {} - client.get_docker_image(request) + await client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_docker_image(request) + await client.get_iam_policy(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_docker_image_rest_required_fields( - request_type=artifact.GetDockerImageRequest, +@pytest.mark.asyncio +async def test_get_iam_policy_async( + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # 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() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_docker_image._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + ) + response = await client.get_iam_policy(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = iam_policy_pb2.GetIamPolicyRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # 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" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_docker_image._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_get_iam_policy_async_from_dict(): + await test_get_iam_policy_async(request_type=dict) + +def test_get_iam_policy_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.DockerImage() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # 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() - # Convert return value to protobuf type - return_value = artifact.DockerImage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.resource = "resource_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_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) - response = client.get_docker_image(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 - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] -def test_get_docker_image_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_iam_policy_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.get_docker_image._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("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 = iam_policy_pb2.GetIamPolicyRequest() + + request.resource = "resource_value" + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) + await client.get_iam_policy(request) -def test_get_docker_image_rest_flattened(): + # 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", + "resource=resource_value", + ) in kw["metadata"] + + +def test_get_iam_policy_from_dict_foreign(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = policy_pb2.Policy() + response = client.get_iam_policy( + request={ + "resource": "resource_value", + "options": options_pb2.GetPolicyOptions(requested_policy_version=2598), + } + ) + call.assert_called() - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = artifact.DockerImage() - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4" - } +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], +) +def test_test_iam_permissions(request_type, transport: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) + # 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() - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.DockerImage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) + response = client.test_iam_permissions(request) - client.get_docker_image(**mock_args) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = iam_policy_pb2.TestIamPermissionsRequest() + assert args[0] == request - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/dockerImages/*}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert response.permissions == ["permissions_value"] -def test_get_docker_image_rest_flattened_error(transport: str = "rest"): +def test_test_iam_permissions_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="grpc", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_docker_image( - artifact.GetDockerImageRequest(), - name="name_value", + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.test_iam_permissions(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", ) -def test_list_maven_artifacts_rest_use_cached_wrapped_rpc(): +def test_test_iam_permissions_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -15309,7 +16141,7 @@ def test_list_maven_artifacts_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.list_maven_artifacts in client._transport._wrapped_methods + client._transport.test_iam_permissions in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -15318,251 +16150,271 @@ def test_list_maven_artifacts_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.list_maven_artifacts + client._transport.test_iam_permissions ] = mock_rpc - request = {} - client.list_maven_artifacts(request) + client.test_iam_permissions(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_maven_artifacts(request) + client.test_iam_permissions(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_maven_artifacts_rest_required_fields( - request_type=artifact.ListMavenArtifactsRequest, +@pytest.mark.asyncio +async def test_test_iam_permissions_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ArtifactRegistryRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.test_iam_permissions + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_maven_artifacts._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.test_iam_permissions + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.test_iam_permissions(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_maven_artifacts._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) + await client.test_iam_permissions(request) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_test_iam_permissions_async( + transport: str = "grpc_asyncio", + request_type=iam_policy_pb2.TestIamPermissionsRequest, +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = artifact.ListMavenArtifactsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # 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() - response_value = Response() - response_value.status_code = 200 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) + ) + response = await client.test_iam_permissions(request) - # Convert return value to protobuf type - return_value = artifact.ListMavenArtifactsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = iam_policy_pb2.TestIamPermissionsRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the response is the type that we expect. + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert response.permissions == ["permissions_value"] - response = client.list_maven_artifacts(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_test_iam_permissions_async_from_dict(): + await test_test_iam_permissions_async(request_type=dict) -def test_list_maven_artifacts_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_test_iam_permissions_field_headers(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.list_maven_artifacts._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = iam_policy_pb2.TestIamPermissionsRequest() + request.resource = "resource_value" -def test_list_maven_artifacts_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + # 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) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListMavenArtifactsResponse() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.ListMavenArtifactsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_test_iam_permissions_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) - client.list_maven_artifacts(**mock_args) + # 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() - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*}/mavenArtifacts" - % client.transport._host, - args[1], + request.resource = "resource_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: + call.return_value = 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) + _, 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", + "resource=resource_value", + ) in kw["metadata"] -def test_list_maven_artifacts_rest_flattened_error(transport: str = "rest"): + +def test_test_iam_permissions_from_dict_foreign(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) - - # 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", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + response = client.test_iam_permissions( + request={ + "resource": "resource_value", + "permissions": ["permissions_value"], + } ) + call.assert_called() -def test_list_maven_artifacts_rest_pager(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + settings.GetProjectSettingsRequest, + dict, + ], +) +def test_get_project_settings(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response + # 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() - # Wrap the values into proper Response objs - response = tuple( - artifact.ListMavenArtifactsResponse.to_json(x) for x in response + # 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( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + pull_percent=1293, ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + response = client.get_project_settings(request) - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = settings.GetProjectSettingsRequest() + assert args[0] == request - pager = client.list_maven_artifacts(request=sample_request) + # Establish that the response is the type that we expect. + assert isinstance(response, settings.ProjectSettings) + assert response.name == "name_value" + assert ( + response.legacy_redirection_state + == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED + ) + assert response.pull_percent == 1293 - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.MavenArtifact) for i in results) - pages = list(client.list_maven_artifacts(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +def test_get_project_settings_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = settings.GetProjectSettingsRequest( + name="name_value", + ) -def test_get_maven_artifact_rest_use_cached_wrapped_rpc(): + # 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.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_project_settings(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == settings.GetProjectSettingsRequest( + name="name_value", + ) + + +def test_get_project_settings_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -15571,7 +16423,7 @@ def test_get_maven_artifact_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.get_maven_artifact in client._transport._wrapped_methods + client._transport.get_project_settings in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -15580,429 +16432,340 @@ def test_get_maven_artifact_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.get_maven_artifact + client._transport.get_project_settings ] = mock_rpc - request = {} - client.get_maven_artifact(request) + client.get_project_settings(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_maven_artifact(request) + client.get_project_settings(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_maven_artifact_rest_required_fields( - request_type=artifact.GetMavenArtifactRequest, +@pytest.mark.asyncio +async def test_get_project_settings_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ArtifactRegistryRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.get_project_settings + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_maven_artifact._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_project_settings + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.get_project_settings(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_maven_artifact._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + await client.get_project_settings(request) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_get_project_settings_async( + transport: str = "grpc_asyncio", request_type=settings.GetProjectSettingsRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = artifact.MavenArtifact() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # 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() - response_value = Response() - response_value.status_code = 200 + # 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 = grpc_helpers_async.FakeUnaryUnaryCall( + settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + pull_percent=1293, + ) + ) + response = await client.get_project_settings(request) - # Convert return value to protobuf type - return_value = artifact.MavenArtifact.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = settings.GetProjectSettingsRequest() + assert args[0] == request - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Establish that the response is the type that we expect. + assert isinstance(response, settings.ProjectSettings) + assert response.name == "name_value" + assert ( + response.legacy_redirection_state + == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED + ) + assert response.pull_percent == 1293 - response = client.get_maven_artifact(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_get_project_settings_async_from_dict(): + await test_get_project_settings_async(request_type=dict) -def test_get_maven_artifact_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_get_project_settings_field_headers(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.get_maven_artifact._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("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 = settings.GetProjectSettingsRequest() + request.name = "name_value" -def test_get_maven_artifact_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + # 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) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = artifact.MavenArtifact() + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4" - } + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.MavenArtifact.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_get_project_settings_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) - client.get_maven_artifact(**mock_args) + # 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() - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/mavenArtifacts/*}" - % client.transport._host, - args[1], + 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 = 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) + _, args, _ = call.mock_calls[0] + assert args[0] == request -def test_get_maven_artifact_rest_flattened_error(transport: str = "rest"): + # 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_project_settings_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_maven_artifact( - artifact.GetMavenArtifactRequest(), - name="name_value", - ) - - -def test_list_npm_packages_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_npm_packages in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + # 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 the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_project_settings( + name="name_value", ) - client._transport._wrapped_methods[ - client._transport.list_npm_packages - ] = mock_rpc - - request = {} - client.list_npm_packages(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_npm_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_npm_packages_rest_required_fields( - request_type=artifact.ListNpmPackagesRequest, -): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_npm_packages._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_npm_packages._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) + # 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 - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +def test_get_project_settings_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.ListNpmPackagesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListNpmPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.list_npm_packages(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_list_npm_packages_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_npm_packages._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) + # 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", ) - & set(("parent",)) - ) -def test_list_npm_packages_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", +@pytest.mark.asyncio +async def test_get_project_settings_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListNpmPackagesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } + # 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() - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + 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", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.ListNpmPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_npm_packages(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*}/npmPackages" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_list_npm_packages_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_get_project_settings_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_npm_packages( - artifact.ListNpmPackagesRequest(), - parent="parent_value", + await client.get_project_settings( + settings.GetProjectSettingsRequest(), + name="name_value", ) -def test_list_npm_packages_rest_pager(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + settings.UpdateProjectSettingsRequest, + dict, + ], +) +def test_update_project_settings(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), + # 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_project_settings), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + pull_percent=1293, ) - # Two responses for two calls - response = response + response + response = client.update_project_settings(request) - # Wrap the values into proper Response objs - response = tuple(artifact.ListNpmPackagesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = settings.UpdateProjectSettingsRequest() + assert args[0] == request - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } + # Establish that the response is the type that we expect. + assert isinstance(response, settings.ProjectSettings) + assert response.name == "name_value" + assert ( + response.legacy_redirection_state + == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED + ) + assert response.pull_percent == 1293 - pager = client.list_npm_packages(request=sample_request) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.NpmPackage) for i in results) +def test_update_project_settings_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) - pages = list(client.list_npm_packages(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = settings.UpdateProjectSettingsRequest() + + # 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: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_project_settings(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == settings.UpdateProjectSettingsRequest() -def test_get_npm_package_rest_use_cached_wrapped_rpc(): +def test_update_project_settings_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -16010,439 +16773,356 @@ def test_get_npm_package_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_npm_package in client._transport._wrapped_methods + assert ( + client._transport.update_project_settings + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_npm_package] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.update_project_settings + ] = mock_rpc request = {} - client.get_npm_package(request) + client.update_project_settings(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_npm_package(request) + client.update_project_settings(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_npm_package_rest_required_fields( - request_type=artifact.GetNpmPackageRequest, +@pytest.mark.asyncio +async def test_update_project_settings_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_npm_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - # verify required fields with default values are now present + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - jsonified_request["name"] = "name_value" + # Ensure method has been cached + assert ( + client._client._transport.update_project_settings + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_npm_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_project_settings + ] = mock_rpc - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + request = {} + await client.update_project_settings(request) - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # Designate an appropriate value for the returned response. - return_value = artifact.NpmPackage() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + await client.update_project_settings(request) - response_value = Response() - response_value.status_code = 200 + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Convert return value to protobuf type - return_value = artifact.NpmPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value +@pytest.mark.asyncio +async def test_update_project_settings_async( + transport: str = "grpc_asyncio", request_type=settings.UpdateProjectSettingsRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - response = client.get_npm_package(request) + # 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() - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # 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 = grpc_helpers_async.FakeUnaryUnaryCall( + settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + pull_percent=1293, + ) + ) + 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] + request = settings.UpdateProjectSettingsRequest() + assert args[0] == request -def test_get_npm_package_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials + # Establish that the response is the type that we expect. + assert isinstance(response, settings.ProjectSettings) + assert response.name == "name_value" + assert ( + response.legacy_redirection_state + == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED ) + assert response.pull_percent == 1293 - unset_fields = transport.get_npm_package._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) +@pytest.mark.asyncio +async def test_update_project_settings_async_from_dict(): + await test_update_project_settings_async(request_type=dict) -def test_get_npm_package_rest_flattened(): + +def test_update_project_settings_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = artifact.NpmPackage() + # 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() - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4" - } + request.project_settings.name = "name_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) + # 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: + call.return_value = settings.ProjectSettings() + client.update_project_settings(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.NpmPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.get_npm_package(**mock_args) + # 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 underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/npmPackages/*}" - % client.transport._host, - args[1], - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_settings.name=name_value", + ) in kw["metadata"] -def test_get_npm_package_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_update_project_settings_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_npm_package( - artifact.GetNpmPackageRequest(), - name="name_value", - ) - - -def test_list_python_packages_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # 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() - # Ensure method has been cached - assert ( - client._transport.list_python_packages in client._transport._wrapped_methods - ) + request.project_settings.name = "name_value" - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + # 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: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + settings.ProjectSettings() ) - client._transport._wrapped_methods[ - client._transport.list_python_packages - ] = mock_rpc - - request = {} - client.list_python_packages(request) + await client.update_project_settings(request) # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_python_packages(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_python_packages_rest_required_fields( - request_type=artifact.ListPythonPackagesRequest, -): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_python_packages._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_python_packages._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_settings.name=name_value", + ) in kw["metadata"] - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +def test_update_project_settings_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = artifact.ListPythonPackagesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListPythonPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.list_python_packages(request) + # 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 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"]), + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # 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_list_python_packages_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_update_project_settings_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.list_python_packages._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) + # 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"]), ) - & set(("parent",)) - ) -def test_list_python_packages_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", +@pytest.mark.asyncio +async def test_update_project_settings_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = artifact.ListPythonPackagesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } + # 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() - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + 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"]), ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.ListPythonPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_python_packages(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*}/pythonPackages" - % client.transport._host, - args[1], - ) + 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 -def test_list_python_packages_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_update_project_settings_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_python_packages( - artifact.ListPythonPackagesRequest(), - parent="parent_value", + await client.update_project_settings( + settings.UpdateProjectSettingsRequest(), + project_settings=settings.ProjectSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_list_python_packages_rest_pager(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + vpcsc_config.GetVPCSCConfigRequest, + dict, + ], +) +def test_get_vpcsc_config(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), - ) - # Two responses for two calls - response = response + response + # 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() - # Wrap the values into proper Response objs - response = tuple( - artifact.ListPythonPackagesResponse.to_json(x) for x in response + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = vpcsc_config.VPCSCConfig( + name="name_value", + vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + response = client.get_vpcsc_config(request) - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = vpcsc_config.GetVPCSCConfigRequest() + assert args[0] == request - pager = client.list_python_packages(request=sample_request) + # Establish that the response is the type that we expect. + assert isinstance(response, vpcsc_config.VPCSCConfig) + assert response.name == "name_value" + assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, artifact.PythonPackage) for i in results) - pages = list(client.list_python_packages(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +def test_get_vpcsc_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = vpcsc_config.GetVPCSCConfigRequest( + name="name_value", + ) -def test_get_python_package_rest_use_cached_wrapped_rpc(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_vpcsc_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vpcsc_config.GetVPCSCConfigRequest( + name="name_value", + ) + + +def test_get_vpcsc_config_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -16450,9 +17130,7 @@ def test_get_python_package_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.get_python_package in client._transport._wrapped_methods - ) + assert client._transport.get_vpcsc_config in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -16460,215 +17138,320 @@ def test_get_python_package_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.get_python_package + client._transport.get_vpcsc_config ] = mock_rpc - request = {} - client.get_python_package(request) + client.get_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_python_package(request) + client.get_vpcsc_config(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_python_package_rest_required_fields( - request_type=artifact.GetPythonPackageRequest, +@pytest.mark.asyncio +async def test_get_vpcsc_config_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ArtifactRegistryRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_vpcsc_config + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_vpcsc_config + ] = mock_rpc + + request = {} + await client.get_vpcsc_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_vpcsc_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_vpcsc_config_async( + transport: str = "grpc_asyncio", request_type=vpcsc_config.GetVPCSCConfigRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # 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() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_python_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + 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( + vpcsc_config.VPCSCConfig( + name="name_value", + vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, + ) + ) + response = await client.get_vpcsc_config(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = vpcsc_config.GetVPCSCConfigRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # Establish that the response is the type that we expect. + assert isinstance(response, vpcsc_config.VPCSCConfig) + assert response.name == "name_value" + assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_python_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_get_vpcsc_config_async_from_dict(): + await test_get_vpcsc_config_async(request_type=dict) + +def test_get_vpcsc_config_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = artifact.PythonPackage() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 + # 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 = vpcsc_config.GetVPCSCConfigRequest() - # Convert return value to protobuf type - return_value = artifact.PythonPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the 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) - 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] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # 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_python_package_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_vpcsc_config_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.get_python_package._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("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 = vpcsc_config.GetVPCSCConfigRequest() + request.name = "name_value" -def test_get_python_package_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vpcsc_config.VPCSCConfig() + ) + 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] == 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_vpcsc_config_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = artifact.PythonPackage() - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4" - } - - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + # Designate an appropriate return value for the call. + 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_vpcsc_config( name="name_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = artifact.PythonPackage.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.get_python_package(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/pythonPackages/*}" - % client.transport._host, - args[1], - ) + 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_python_package_rest_flattened_error(transport: str = "rest"): +def test_get_vpcsc_config_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_python_package( - artifact.GetPythonPackageRequest(), + client.get_vpcsc_config( + vpcsc_config.GetVPCSCConfigRequest(), name="name_value", ) -def test_import_apt_artifacts_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +@pytest.mark.asyncio +async def test_get_vpcsc_config_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_vpcsc_config), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = vpcsc_config.VPCSCConfig() - # Ensure method has been cached - assert ( - client._transport.import_apt_artifacts in client._transport._wrapped_methods + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + 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_vpcsc_config( + name="name_value", ) - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + # 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_vpcsc_config_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_vpcsc_config( + vpcsc_config.GetVPCSCConfigRequest(), + name="name_value", ) - client._transport._wrapped_methods[ - client._transport.import_apt_artifacts - ] = mock_rpc - request = {} - client.import_apt_artifacts(request) + +@pytest.mark.parametrize( + "request_type", + [ + gda_vpcsc_config.UpdateVPCSCConfigRequest, + dict, + ], +) +def test_update_vpcsc_config(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_vpcsc_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gda_vpcsc_config.VPCSCConfig( + name="name_value", + vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, + ) + response = client.update_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gda_vpcsc_config.UpdateVPCSCConfigRequest() + assert args[0] == request - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() + # Establish that the response is the type that we expect. + assert isinstance(response, gda_vpcsc_config.VPCSCConfig) + assert response.name == "name_value" + assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - client.import_apt_artifacts(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +def test_update_vpcsc_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = gda_vpcsc_config.UpdateVPCSCConfigRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vpcsc_config), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_vpcsc_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gda_vpcsc_config.UpdateVPCSCConfigRequest() -def test_import_yum_artifacts_rest_use_cached_wrapped_rpc(): +def test_update_vpcsc_config_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -16677,7 +17460,7 @@ def test_import_yum_artifacts_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.import_yum_artifacts in client._transport._wrapped_methods + client._transport.update_vpcsc_config in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -16686,33 +17469,31 @@ def test_import_yum_artifacts_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.import_yum_artifacts + client._transport.update_vpcsc_config ] = mock_rpc - request = {} - client.import_yum_artifacts(request) + client.update_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.import_yum_artifacts(request) + client.update_vpcsc_config(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_repositories_rest_use_cached_wrapped_rpc(): +@pytest.mark.asyncio +async def test_update_vpcsc_config_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) # Should wrap all calls on client creation @@ -16720,255 +17501,305 @@ def test_list_repositories_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_repositories in client._transport._wrapped_methods + assert ( + client._client._transport.update_vpcsc_config + in client._client._transport._wrapped_methods + ) # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.list_repositories + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_vpcsc_config ] = mock_rpc request = {} - client.list_repositories(request) + await client.update_vpcsc_config(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_repositories(request) + await client.update_vpcsc_config(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_repositories_rest_required_fields( - request_type=repository.ListRepositoriesRequest, +@pytest.mark.asyncio +async def test_update_vpcsc_config_async( + transport: str = "grpc_asyncio", + request_type=gda_vpcsc_config.UpdateVPCSCConfigRequest, ): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # 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() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_repositories._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vpcsc_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_vpcsc_config.VPCSCConfig( + name="name_value", + vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, + ) + ) + response = await client.update_vpcsc_config(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gda_vpcsc_config.UpdateVPCSCConfigRequest() + assert args[0] == request - jsonified_request["parent"] = "parent_value" + # Establish that the response is the type that we expect. + assert isinstance(response, gda_vpcsc_config.VPCSCConfig) + assert response.name == "name_value" + assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_repositories._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" +@pytest.mark.asyncio +async def test_update_vpcsc_config_async_from_dict(): + await test_update_vpcsc_config_async(request_type=dict) + +def test_update_vpcsc_config_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - response = client.list_repositories(request) + # 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_vpcsc_config.UpdateVPCSCConfigRequest() - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + 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_vpcsc_config), "__call__" + ) as call: + call.return_value = gda_vpcsc_config.VPCSCConfig() + client.update_vpcsc_config(request) -def test_list_repositories_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - unset_fields = transport.list_repositories._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "vpcsc_config.name=name_value", + ) in kw["metadata"] -def test_list_repositories_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", +@pytest.mark.asyncio +async def test_update_vpcsc_config_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse() + # 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_vpcsc_config.UpdateVPCSCConfigRequest() - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} + request.vpcsc_config.name = "name_value" - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vpcsc_config), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_vpcsc_config.VPCSCConfig() ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + await client.update_vpcsc_config(request) - client.list_repositories(**mock_args) + # 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 underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/repositories" - % client.transport._host, - args[1], - ) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "vpcsc_config.name=name_value", + ) in kw["metadata"] -def test_list_repositories_rest_flattened_error(transport: str = "rest"): +def test_update_vpcsc_config_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) - # 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", - ) - - -def test_list_repositories_rest_pager(transport: str = "rest"): - client = ArtifactRegistryClient( - 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.update_vpcsc_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + 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_vpcsc_config( + vpcsc_config=gda_vpcsc_config.VPCSCConfig(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].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_vpcsc_config_flattened_error(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + 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"]), ) - # Two responses for two calls - response = response + response - # Wrap the values into proper Response objs - response = tuple( - repository.ListRepositoriesResponse.to_json(x) for x in response + +@pytest.mark.asyncio +async def test_update_vpcsc_config_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vpcsc_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = gda_vpcsc_config.VPCSCConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + 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_vpcsc_config( + vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - sample_request = {"parent": "projects/sample1/locations/sample2"} + # 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].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 - pager = client.list_repositories(request=sample_request) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, repository.Repository) for i in results) +@pytest.mark.asyncio +async def test_update_vpcsc_config_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) - pages = list(client.list_repositories(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + 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"]), + ) -def test_get_repository_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + gda_package.UpdatePackageRequest, + dict, + ], +) +def test_update_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.update_package), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gda_package.Package( + name="name_value", + display_name="display_name_value", + ) + response = client.update_package(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gda_package.UpdatePackageRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, gda_package.Package) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + + +def test_update_package_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = gda_package.UpdatePackageRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_package(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gda_package.UpdatePackageRequest() + + +def test_update_package_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -16976,177 +17807,334 @@ def test_get_repository_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_repository in client._transport._wrapped_methods + assert client._transport.update_package in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_repository] = mock_rpc - + client._transport._wrapped_methods[client._transport.update_package] = mock_rpc request = {} - client.get_repository(request) + client.update_package(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_repository(request) + client.update_package(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_repository_rest_required_fields( - request_type=repository.GetRepositoryRequest, +@pytest.mark.asyncio +async def test_update_package_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ArtifactRegistryRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.update_package + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_package + ] = mock_rpc + + request = {} + await client.update_package(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.update_package(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_package_async( + transport: str = "grpc_asyncio", request_type=gda_package.UpdatePackageRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # 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() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_package.Package( + name="name_value", + display_name="display_name_value", + ) + ) + response = await client.update_package(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gda_package.UpdatePackageRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # Establish that the response is the type that we expect. + assert isinstance(response, gda_package.Package) + assert response.name == "name_value" + assert response.display_name == "display_name_value" - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_update_package_async_from_dict(): + await test_update_package_async(request_type=dict) + +def test_update_package_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = repository.Repository() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # 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_package.UpdatePackageRequest() - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.package.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + call.return_value = gda_package.Package() + client.update_package(request) - 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] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "package.name=name_value", + ) in kw["metadata"] -def test_get_repository_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_update_package_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.get_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("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 = gda_package.UpdatePackageRequest() + request.package.name = "name_value" -def test_get_repository_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_package.Package()) + await client.update_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", + "package.name=name_value", + ) in kw["metadata"] + + +def test_update_package_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = repository.Repository() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gda_package.Package() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_package( + package=gda_package.Package(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3" - } + # 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].package + mock_val = gda_package.Package(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 - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + +def test_update_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.update_package( + gda_package.UpdatePackageRequest(), + package=gda_package.Package(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.get_repository(**mock_args) +@pytest.mark.asyncio +async def test_update_package_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gda_package.Package() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gda_package.Package()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_package( + package=gda_package.Package(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(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*}" - % client.transport._host, - args[1], + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].package + mock_val = gda_package.Package(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_package_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_package( + gda_package.UpdatePackageRequest(), + package=gda_package.Package(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_get_repository_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + attachment.ListAttachmentsRequest, + dict, + ], +) +def test_list_attachments(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # 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", + # 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_attachments), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = attachment.ListAttachmentsResponse( + next_page_token="next_page_token_value", ) + response = client.list_attachments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = attachment.ListAttachmentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAttachmentsPager) + assert response.next_page_token == "next_page_token_value" -def test_create_repository_rest_use_cached_wrapped_rpc(): +def test_list_attachments_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = attachment.ListAttachmentsRequest( + parent="parent_value", + filter="filter_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_attachments(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == attachment.ListAttachmentsRequest( + parent="parent_value", + filter="filter_value", + page_token="page_token_value", + ) + + +def test_list_attachments_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -17154,7 +18142,7 @@ def test_create_repository_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.create_repository in client._transport._wrapped_methods + assert client._transport.list_attachments in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -17162,314 +18150,520 @@ def test_create_repository_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.create_repository + client._transport.list_attachments ] = mock_rpc - request = {} - client.create_repository(request) + client.list_attachments(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_repository(request) + client.list_attachments(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_create_repository_rest_required_fields( - request_type=gda_repository.CreateRepositoryRequest, +@pytest.mark.asyncio +async def test_list_attachments_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["repository_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - # verify fields with default values are dropped - assert "repositoryId" not in jsonified_request + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Ensure method has been cached + assert ( + client._client._transport.list_attachments + in client._client._transport._wrapped_methods + ) - # verify required fields with default values are now present - assert "repositoryId" in jsonified_request - assert jsonified_request["repositoryId"] == request_init["repository_id"] + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_attachments + ] = mock_rpc - jsonified_request["parent"] = "parent_value" - jsonified_request["repositoryId"] = "repository_id_value" + request = {} + await client.list_attachments(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_repository._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("repository_id",)) - jsonified_request.update(unset_fields) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - assert "repositoryId" in jsonified_request - assert jsonified_request["repositoryId"] == "repository_id_value" + await client.list_attachments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_attachments_async( + transport: str = "grpc_asyncio", request_type=attachment.ListAttachmentsRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + 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_attachments), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + attachment.ListAttachmentsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_attachments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = attachment.ListAttachmentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAttachmentsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_attachments_async_from_dict(): + await test_list_attachments_async(request_type=dict) + +def test_list_attachments_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # 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 = attachment.ListAttachmentsRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.parent = "parent_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + call.return_value = attachment.ListAttachmentsResponse() + client.list_attachments(request) - 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] == request - expected_params = [ - ( - "repositoryId", - "", - ), - ("$alt", "json;enum-encoding=int"), - ] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # 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_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_list_attachments_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.create_repository._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("repositoryId",)) - & set( - ( - "parent", - "repositoryId", - "repository", - ) + # 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 = attachment.ListAttachmentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + attachment.ListAttachmentsResponse() ) - ) + await client.list_attachments(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_create_repository_rest_flattened(): + # 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_attachments_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = attachment.ListAttachmentsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_attachments( parent="parent_value", - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - repository_id="repository_id_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.create_repository(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/repositories" - % client.transport._host, - args[1], - ) + 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_create_repository_rest_flattened_error(transport: str = "rest"): +def test_list_attachments_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # 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(), + client.list_attachments( + attachment.ListAttachmentsRequest(), parent="parent_value", - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) - ), - repository_id="repository_id_value", ) -def test_update_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", +@pytest.mark.asyncio +async def test_list_attachments_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = attachment.ListAttachmentsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + attachment.ListAttachmentsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_attachments( + parent="parent_value", ) - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # 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 - # Ensure method has been cached - assert client._transport.update_repository in client._transport._wrapped_methods - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. +@pytest.mark.asyncio +async def test_list_attachments_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_attachments( + attachment.ListAttachmentsRequest(), + parent="parent_value", ) - client._transport._wrapped_methods[ - client._transport.update_repository - ] = mock_rpc - request = {} - client.update_repository(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 +def test_list_attachments_pager(transport_name: str = "grpc"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) - client.update_repository(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + attachment.Attachment(), + ], + next_page_token="abc", + ), + attachment.ListAttachmentsResponse( + attachments=[], + next_page_token="def", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + ], + next_page_token="ghi", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + ], + ), + RuntimeError, + ) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_attachments(request={}, retry=retry, timeout=timeout) + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout -def test_update_repository_rest_flattened(): + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, attachment.Attachment) for i in results) + + +def test_list_attachments_pages(transport_name: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport_name, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = gda_repository.Repository() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + attachment.Attachment(), + ], + next_page_token="abc", + ), + attachment.ListAttachmentsResponse( + attachments=[], + next_page_token="def", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + ], + next_page_token="ghi", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + ], + ), + RuntimeError, + ) + pages = list(client.list_attachments(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # get arguments that satisfy an http rule for this method - sample_request = { - "repository": { - "name": "projects/sample1/locations/sample2/repositories/sample3" - } - } - # get truthy value for each flattened field - mock_args = dict( - repository=gda_repository.Repository( - maven_config=gda_repository.Repository.MavenRepositoryConfig( - allow_snapshot_overwrites=True - ) +@pytest.mark.asyncio +async def test_list_attachments_async_pager(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_attachments), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + attachment.Attachment(), + ], + next_page_token="abc", ), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + attachment.ListAttachmentsResponse( + attachments=[], + next_page_token="def", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + ], + next_page_token="ghi", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + ], + ), + RuntimeError, ) - mock_args.update(sample_request) + async_pager = await client.list_attachments( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_repository.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + assert len(responses) == 6 + assert all(isinstance(i, attachment.Attachment) for i in responses) - client.update_repository(**mock_args) - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{repository.name=projects/*/locations/*/repositories/*}" - % client.transport._host, - args[1], +@pytest.mark.asyncio +async def test_list_attachments_async_pages(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_attachments), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + attachment.Attachment(), + ], + next_page_token="abc", + ), + attachment.ListAttachmentsResponse( + attachments=[], + next_page_token="def", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + ], + next_page_token="ghi", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + ], + ), + RuntimeError, ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_attachments(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -def test_update_repository_rest_flattened_error(transport: str = "rest"): +@pytest.mark.parametrize( + "request_type", + [ + attachment.GetAttachmentRequest, + dict, + ], +) +def test_get_attachment(request_type, transport: str = "grpc"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) - # 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"]), + # 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_attachment), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = attachment.Attachment( + name="name_value", + target="target_value", + type_="type__value", + attachment_namespace="attachment_namespace_value", + files=["files_value"], + oci_version_name="oci_version_name_value", ) + response = client.get_attachment(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = attachment.GetAttachmentRequest() + assert args[0] == request -def test_delete_repository_rest_use_cached_wrapped_rpc(): + # Establish that the response is the type that we expect. + assert isinstance(response, attachment.Attachment) + assert response.name == "name_value" + assert response.target == "target_value" + assert response.type_ == "type__value" + assert response.attachment_namespace == "attachment_namespace_value" + assert response.files == ["files_value"] + assert response.oci_version_name == "oci_version_name_value" + + +def test_get_attachment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = attachment.GetAttachmentRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_attachment), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_attachment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == attachment.GetAttachmentRequest( + name="name_value", + ) + + +def test_get_attachment_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -17477,178 +18671,335 @@ def test_delete_repository_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_repository in client._transport._wrapped_methods + assert client._transport.get_attachment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.delete_repository - ] = mock_rpc - + client._transport._wrapped_methods[client._transport.get_attachment] = mock_rpc request = {} - client.delete_repository(request) + client.get_attachment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_repository(request) + client.get_attachment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_repository_rest_required_fields( - request_type=repository.DeleteRepositoryRequest, +@pytest.mark.asyncio +async def test_get_attachment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - # verify fields with default values are dropped + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Ensure method has been cached + assert ( + client._client._transport.get_attachment + in client._client._transport._wrapped_methods + ) - # verify required fields with default values are now present + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_attachment + ] = mock_rpc - jsonified_request["name"] = "name_value" + request = {} + await client.get_attachment(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + await client.get_attachment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_attachment_async( + transport: str = "grpc_asyncio", request_type=attachment.GetAttachmentRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + 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_attachment), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + attachment.Attachment( + name="name_value", + target="target_value", + type_="type__value", + attachment_namespace="attachment_namespace_value", + files=["files_value"], + oci_version_name="oci_version_name_value", + ) + ) + response = await client.get_attachment(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = attachment.GetAttachmentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, attachment.Attachment) + assert response.name == "name_value" + assert response.target == "target_value" + assert response.type_ == "type__value" + assert response.attachment_namespace == "attachment_namespace_value" + assert response.files == ["files_value"] + assert response.oci_version_name == "oci_version_name_value" + + +@pytest.mark.asyncio +async def test_get_attachment_async_from_dict(): + await test_get_attachment_async(request_type=dict) + + +def test_get_attachment_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # 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 = attachment.GetAttachmentRequest() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_attachment), "__call__") as call: + call.return_value = attachment.Attachment() + client.get_attachment(request) - 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] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # 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_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_get_attachment_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.delete_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("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 = attachment.GetAttachmentRequest() + request.name = "name_value" -def test_delete_repository_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_attachment), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + attachment.Attachment() + ) + await client.get_attachment(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_attachment_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_attachment), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = attachment.Attachment() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_attachment( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3" - } + # 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 - # get truthy value for each flattened field - mock_args = dict( + +def test_get_attachment_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_attachment( + attachment.GetAttachmentRequest(), name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.delete_repository(**mock_args) +@pytest.mark.asyncio +async def test_get_attachment_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_attachment), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = attachment.Attachment() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + attachment.Attachment() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_attachment( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_delete_repository_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_get_attachment_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) # 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(), + await client.get_attachment( + attachment.GetAttachmentRequest(), name="name_value", ) -def test_list_packages_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + gda_attachment.CreateAttachmentRequest, + dict, + ], +) +def test_create_attachment(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_attachment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_attachment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = gda_attachment.CreateAttachmentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_attachment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = gda_attachment.CreateAttachmentRequest( + parent="parent_value", + attachment_id="attachment_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_attachment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_attachment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == gda_attachment.CreateAttachmentRequest( + parent="parent_value", + attachment_id="attachment_id_value", + ) + + +def test_create_attachment_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -17656,253 +19007,362 @@ def test_list_packages_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_packages in client._transport._wrapped_methods + assert client._transport.create_attachment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_packages] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.create_attachment + ] = mock_rpc request = {} - client.list_packages(request) + client.create_attachment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_packages(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_attachment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_packages_rest_required_fields(request_type=package.ListPackagesRequest): - transport_class = transports.ArtifactRegistryRestTransport +@pytest.mark.asyncio +async def test_create_attachment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.create_attachment + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_packages._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_attachment + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.create_attachment(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_packages._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_attachment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_attachment_async( + transport: str = "grpc_asyncio", request_type=gda_attachment.CreateAttachmentRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # 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_attachment), "__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_attachment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = gda_attachment.CreateAttachmentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_attachment_async_from_dict(): + await test_create_attachment_async(request_type=dict) + +def test_create_attachment_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = package.ListPackagesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # 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_attachment.CreateAttachmentRequest() - # Convert return value to protobuf type - return_value = package.ListPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.parent = "parent_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_attachment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_attachment(request) - 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] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # 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_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_create_attachment_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.list_packages._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) + # 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_attachment.CreateAttachmentRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_attachment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") ) - & set(("parent",)) - ) + await client.create_attachment(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_rest_flattened(): + # 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_attachment_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = package.ListPackagesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_attachment), "__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_attachment( parent="parent_value", + attachment=gda_attachment.Attachment(name="name_value"), + attachment_id="attachment_id_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = package.ListPackagesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_packages(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*}/packages" - % client.transport._host, - args[1], - ) + 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].attachment + mock_val = gda_attachment.Attachment(name="name_value") + assert arg == mock_val + arg = args[0].attachment_id + mock_val = "attachment_id_value" + assert arg == mock_val -def test_list_packages_rest_flattened_error(transport: str = "rest"): +def test_create_attachment_flattened_error(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # 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(), + client.create_attachment( + gda_attachment.CreateAttachmentRequest(), parent="parent_value", + attachment=gda_attachment.Attachment(name="name_value"), + attachment_id="attachment_id_value", ) -def test_list_packages_rest_pager(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_create_attachment_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - 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(), - ], - ), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_attachment), "__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_attachment( + parent="parent_value", + attachment=gda_attachment.Attachment(name="name_value"), + attachment_id="attachment_id_value", ) - # Two responses for two calls - response = response + response - # Wrap the values into proper Response objs - response = tuple(package.ListPackagesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values + # 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].attachment + mock_val = gda_attachment.Attachment(name="name_value") + assert arg == mock_val + arg = args[0].attachment_id + mock_val = "attachment_id_value" + assert arg == mock_val - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } - pager = client.list_packages(request=sample_request) +@pytest.mark.asyncio +async def test_create_attachment_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, package.Package) for i in results) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_attachment( + gda_attachment.CreateAttachmentRequest(), + parent="parent_value", + attachment=gda_attachment.Attachment(name="name_value"), + attachment_id="attachment_id_value", + ) - pages = list(client.list_packages(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +@pytest.mark.parametrize( + "request_type", + [ + attachment.DeleteAttachmentRequest, + dict, + ], +) +def test_delete_attachment(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() -def test_get_package_rest_use_cached_wrapped_rpc(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_attachment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = attachment.DeleteAttachmentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_attachment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = attachment.DeleteAttachmentRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_attachment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == attachment.DeleteAttachmentRequest( + name="name_value", + ) + + +def test_delete_attachment_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -17910,169 +19370,271 @@ def test_get_package_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_package in client._transport._wrapped_methods + assert client._transport.delete_attachment in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_package] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.delete_attachment + ] = mock_rpc request = {} - client.get_package(request) + client.delete_attachment(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_package(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_attachment(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_package_rest_required_fields(request_type=package.GetPackageRequest): - transport_class = transports.ArtifactRegistryRestTransport +@pytest.mark.asyncio +async def test_delete_attachment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.delete_attachment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_attachment + ] = mock_rpc + + request = {} + await client.delete_attachment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_attachment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_attachment_async( + transport: str = "grpc_asyncio", request_type=attachment.DeleteAttachmentRequest +): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - # verify fields with default values are dropped + # 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() - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__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_attachment(request) - # verify required fields with default values are now present + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = attachment.DeleteAttachmentRequest() + assert args[0] == request - jsonified_request["name"] = "name_value" + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_package._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" +@pytest.mark.asyncio +async def test_delete_attachment_async_from_dict(): + await test_delete_attachment_async(request_type=dict) + +def test_delete_attachment_field_headers(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = package.Package() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # 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 = attachment.DeleteAttachmentRequest() - # Convert return value to protobuf type - return_value = package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.name = "name_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_attachment(request) - 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] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # 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_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_delete_attachment_field_headers_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.get_package._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("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 = attachment.DeleteAttachmentRequest() + request.name = "name_value" -def test_get_package_rest_flattened(): + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.delete_attachment(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_attachment_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = package.Package() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__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_attachment( + name="name_value", + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" - } + # 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 - # get truthy value for each flattened field - mock_args = dict( + +def test_delete_attachment_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_attachment( + attachment.DeleteAttachmentRequest(), name="name_value", ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = package.Package.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - client.get_package(**mock_args) +@pytest.mark.asyncio +async def test_delete_attachment_flattened_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__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_attachment( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*}" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val -def test_get_package_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_delete_attachment_flattened_error_async(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), ) # 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(), + await client.delete_attachment( + attachment.DeleteAttachmentRequest(), name="name_value", ) -def test_delete_package_rest_use_cached_wrapped_rpc(): +def test_list_docker_images_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -18086,37 +19648,39 @@ def test_delete_package_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_package in client._transport._wrapped_methods + assert ( + client._transport.list_docker_images in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_package] = mock_rpc + client._transport._wrapped_methods[ + client._transport.list_docker_images + ] = mock_rpc request = {} - client.delete_package(request) + client.list_docker_images(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_package(request) + client.list_docker_images(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_package_rest_required_fields(request_type=package.DeletePackageRequest): +def test_list_docker_images_rest_required_fields( + request_type=artifact.ListDockerImagesRequest, +): transport_class = transports.ArtifactRegistryRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -18127,21 +19691,29 @@ def test_delete_package_rest_required_fields(request_type=package.DeletePackageR unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_package._get_unset_required_fields(jsonified_request) + ).list_docker_images._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).delete_package._get_unset_required_fields(jsonified_request) + ).list_docker_images._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "order_by", + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), @@ -18150,7 +19722,7 @@ def test_delete_package_rest_required_fields(request_type=package.DeletePackageR request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = artifact.ListDockerImagesResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -18162,35 +19734,47 @@ def test_delete_package_rest_required_fields(request_type=package.DeletePackageR pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "delete", + "method": "get", "query_params": pb_request, } transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.ListDockerImagesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_package(request) + response = client.list_docker_images(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_delete_package_rest_unset_required_fields(): +def test_list_docker_images_rest_unset_required_fields(): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.delete_package._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.list_docker_images._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) -def test_delete_package_rest_flattened(): +def test_list_docker_images_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -18199,40 +19783,42 @@ def test_delete_package_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = artifact.ListDockerImagesResponse() # get arguments that satisfy an http rule for this method sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "parent": "projects/sample1/locations/sample2/repositories/sample3" } # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 + # Convert return value to protobuf type + return_value = artifact.ListDockerImagesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_package(**mock_args) + client.list_docker_images(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*}" + "%s/v1/{parent=projects/*/locations/*/repositories/*}/dockerImages" % client.transport._host, args[1], ) -def test_delete_package_rest_flattened_error(transport: str = "rest"): +def test_list_docker_images_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -18241,111 +19827,16 @@ def test_delete_package_rest_flattened_error(transport: str = "rest"): # 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", - ) - - -def test_list_versions_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_versions in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.list_docker_images( + artifact.ListDockerImagesRequest(), + parent="parent_value", ) - client._transport._wrapped_methods[client._transport.list_versions] = mock_rpc - - request = {} - client.list_versions(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_versions(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 -def test_list_versions_rest_flattened(): +def test_list_docker_images_rest_pager(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = version.ListVersionsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" - } - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = version.ListVersionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.list_versions(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/versions" - % client.transport._host, - args[1], - ) - - -def test_list_versions_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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", - ) - - -def test_list_versions_rest_pager(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport=transport, ) # Mock the http request call within the method and fake a response. @@ -18354,28 +19845,28 @@ def test_list_versions_rest_pager(transport: str = "rest"): # with mock.patch.object(path_template, 'transcode') as transcode: # Set the response as a series of pages response = ( - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), - version.Version(), + artifact.ListDockerImagesResponse( + docker_images=[ + artifact.DockerImage(), + artifact.DockerImage(), + artifact.DockerImage(), ], next_page_token="abc", ), - version.ListVersionsResponse( - versions=[], + artifact.ListDockerImagesResponse( + docker_images=[], next_page_token="def", ), - version.ListVersionsResponse( - versions=[ - version.Version(), + artifact.ListDockerImagesResponse( + docker_images=[ + artifact.DockerImage(), ], next_page_token="ghi", ), - version.ListVersionsResponse( - versions=[ - version.Version(), - version.Version(), + artifact.ListDockerImagesResponse( + docker_images=[ + artifact.DockerImage(), + artifact.DockerImage(), ], ), ) @@ -18383,7 +19874,7 @@ def test_list_versions_rest_pager(transport: str = "rest"): response = response + response # Wrap the values into proper Response objs - response = tuple(version.ListVersionsResponse.to_json(x) for x in response) + response = tuple(artifact.ListDockerImagesResponse.to_json(x) for x in response) return_values = tuple(Response() for i in response) for return_val, response_val in zip(return_values, response): return_val._content = response_val.encode("UTF-8") @@ -18391,213 +19882,21 @@ def test_list_versions_rest_pager(transport: str = "rest"): req.side_effect = return_values sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "parent": "projects/sample1/locations/sample2/repositories/sample3" } - pager = client.list_versions(request=sample_request) + pager = client.list_docker_images(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, version.Version) for i in results) + assert all(isinstance(i, artifact.DockerImage) for i in results) - pages = list(client.list_versions(request=sample_request).pages) + pages = list(client.list_docker_images(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_version_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.get_version] = mock_rpc - - request = {} - client.get_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_version_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = version.Version() - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = version.Version.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.get_version(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}" - % client.transport._host, - args[1], - ) - - -def test_get_version_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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", - ) - - -def test_delete_version_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_version in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.delete_version] = mock_rpc - - request = {} - client.delete_version(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_version(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_version_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - client.delete_version(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}" - % client.transport._host, - args[1], - ) - - -def test_delete_version_rest_flattened_error(transport: str = "rest"): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # 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(), - name="name_value", - ) - - -def test_batch_delete_versions_rest_use_cached_wrapped_rpc(): +def test_get_docker_image_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -18611,10 +19910,7 @@ def test_batch_delete_versions_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.batch_delete_versions - in client._transport._wrapped_methods - ) + assert client._transport.get_docker_image in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -18622,33 +19918,29 @@ def test_batch_delete_versions_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.batch_delete_versions + client._transport.get_docker_image ] = mock_rpc request = {} - client.batch_delete_versions(request) + client.get_docker_image(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.batch_delete_versions(request) + client.get_docker_image(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_batch_delete_versions_rest_required_fields( - request_type=version.BatchDeleteVersionsRequest, +def test_get_docker_image_rest_required_fields( + request_type=artifact.GetDockerImageRequest, ): transport_class = transports.ArtifactRegistryRestTransport request_init = {} - request_init["names"] = "" + request_init["name"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -18659,21 +19951,21 @@ def test_batch_delete_versions_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_delete_versions._get_unset_required_fields(jsonified_request) + ).get_docker_image._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["names"] = "names_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).batch_delete_versions._get_unset_required_fields(jsonified_request) + ).get_docker_image._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "names" in jsonified_request - assert jsonified_request["names"] == "names_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), @@ -18682,7 +19974,7 @@ def test_batch_delete_versions_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = artifact.DockerImage() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -18694,36 +19986,38 @@ def test_batch_delete_versions_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.DockerImage.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_delete_versions(request) + response = client.get_docker_image(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_batch_delete_versions_rest_unset_required_fields(): +def test_get_docker_image_rest_unset_required_fields(): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.batch_delete_versions._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("names",))) + unset_fields = transport.get_docker_image._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -def test_batch_delete_versions_rest_flattened(): +def test_get_docker_image_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -18732,41 +20026,42 @@ def test_batch_delete_versions_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = artifact.DockerImage() # get arguments that satisfy an http rule for this method sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4" } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - names=["names_value"], + name="name_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 + # Convert return value to protobuf type + return_value = artifact.DockerImage.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.batch_delete_versions(**mock_args) + client.get_docker_image(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/versions:batchDelete" + "%s/v1/{name=projects/*/locations/*/repositories/*/dockerImages/*}" % client.transport._host, args[1], ) -def test_batch_delete_versions_rest_flattened_error(transport: str = "rest"): +def test_get_docker_image_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -18775,14 +20070,13 @@ def test_batch_delete_versions_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.batch_delete_versions( - version.BatchDeleteVersionsRequest(), - parent="parent_value", - names=["names_value"], + client.get_docker_image( + artifact.GetDockerImageRequest(), + name="name_value", ) -def test_list_files_rest_use_cached_wrapped_rpc(): +def test_list_maven_artifacts_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -18796,29 +20090,35 @@ def test_list_files_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_files in client._transport._wrapped_methods + assert ( + client._transport.list_maven_artifacts in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_files] = mock_rpc + client._transport._wrapped_methods[ + client._transport.list_maven_artifacts + ] = mock_rpc request = {} - client.list_files(request) + client.list_maven_artifacts(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_files(request) + client.list_maven_artifacts(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_files_rest_required_fields(request_type=file.ListFilesRequest): +def test_list_maven_artifacts_rest_required_fields( + request_type=artifact.ListMavenArtifactsRequest, +): transport_class = transports.ArtifactRegistryRestTransport request_init = {} @@ -18833,7 +20133,7 @@ def test_list_files_rest_required_fields(request_type=file.ListFilesRequest): unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_files._get_unset_required_fields(jsonified_request) + ).list_maven_artifacts._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -18842,12 +20142,10 @@ def test_list_files_rest_required_fields(request_type=file.ListFilesRequest): unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).list_files._get_unset_required_fields(jsonified_request) + ).list_maven_artifacts._get_unset_required_fields(jsonified_request) # Check that path parameters and body parameters are not mixing in. assert not set(unset_fields) - set( ( - "filter", - "order_by", "page_size", "page_token", ) @@ -18865,7 +20163,7 @@ def test_list_files_rest_required_fields(request_type=file.ListFilesRequest): request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = file.ListFilesResponse() + return_value = artifact.ListMavenArtifactsResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -18886,30 +20184,28 @@ def test_list_files_rest_required_fields(request_type=file.ListFilesRequest): response_value.status_code = 200 # Convert return value to protobuf type - return_value = file.ListFilesResponse.pb(return_value) + return_value = artifact.ListMavenArtifactsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_files(request) + response = client.list_maven_artifacts(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_list_files_rest_unset_required_fields(): +def test_list_maven_artifacts_rest_unset_required_fields(): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.list_files._get_unset_required_fields({}) + unset_fields = transport.list_maven_artifacts._get_unset_required_fields({}) assert set(unset_fields) == ( set( ( - "filter", - "orderBy", "pageSize", "pageToken", ) @@ -18918,7 +20214,7 @@ def test_list_files_rest_unset_required_fields(): ) -def test_list_files_rest_flattened(): +def test_list_maven_artifacts_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -18927,7 +20223,7 @@ def test_list_files_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = file.ListFilesResponse() + return_value = artifact.ListMavenArtifactsResponse() # get arguments that satisfy an http rule for this method sample_request = { @@ -18944,25 +20240,25 @@ def test_list_files_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = file.ListFilesResponse.pb(return_value) + return_value = artifact.ListMavenArtifactsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_files(**mock_args) + client.list_maven_artifacts(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*}/files" + "%s/v1/{parent=projects/*/locations/*/repositories/*}/mavenArtifacts" % client.transport._host, args[1], ) -def test_list_files_rest_flattened_error(transport: str = "rest"): +def test_list_maven_artifacts_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -18971,13 +20267,13 @@ def test_list_files_rest_flattened_error(transport: str = "rest"): # 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_maven_artifacts( + artifact.ListMavenArtifactsRequest(), parent="parent_value", ) -def test_list_files_rest_pager(transport: str = "rest"): +def test_list_maven_artifacts_rest_pager(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -18989,28 +20285,28 @@ def test_list_files_rest_pager(transport: str = "rest"): # with mock.patch.object(path_template, 'transcode') as transcode: # Set the response as a series of pages response = ( - file.ListFilesResponse( - files=[ - file.File(), - file.File(), - file.File(), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), + artifact.MavenArtifact(), ], next_page_token="abc", ), - file.ListFilesResponse( - files=[], + artifact.ListMavenArtifactsResponse( + maven_artifacts=[], next_page_token="def", ), - file.ListFilesResponse( - files=[ - file.File(), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), ], next_page_token="ghi", ), - file.ListFilesResponse( - files=[ - file.File(), - file.File(), + artifact.ListMavenArtifactsResponse( + maven_artifacts=[ + artifact.MavenArtifact(), + artifact.MavenArtifact(), ], ), ) @@ -19018,7 +20314,9 @@ def test_list_files_rest_pager(transport: str = "rest"): response = response + response # Wrap the values into proper Response objs - response = tuple(file.ListFilesResponse.to_json(x) for x in response) + response = tuple( + artifact.ListMavenArtifactsResponse.to_json(x) for x in response + ) return_values = tuple(Response() for i in response) for return_val, response_val in zip(return_values, response): return_val._content = response_val.encode("UTF-8") @@ -19029,18 +20327,18 @@ def test_list_files_rest_pager(transport: str = "rest"): "parent": "projects/sample1/locations/sample2/repositories/sample3" } - pager = client.list_files(request=sample_request) + pager = client.list_maven_artifacts(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, file.File) for i in results) + assert all(isinstance(i, artifact.MavenArtifact) for i in results) - pages = list(client.list_files(request=sample_request).pages) + pages = list(client.list_maven_artifacts(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_file_rest_use_cached_wrapped_rpc(): +def test_get_maven_artifact_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -19054,29 +20352,35 @@ def test_get_file_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_file in client._transport._wrapped_methods + assert ( + client._transport.get_maven_artifact in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_file] = mock_rpc + client._transport._wrapped_methods[ + client._transport.get_maven_artifact + ] = mock_rpc request = {} - client.get_file(request) + client.get_maven_artifact(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_file(request) + client.get_maven_artifact(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_file_rest_required_fields(request_type=file.GetFileRequest): +def test_get_maven_artifact_rest_required_fields( + request_type=artifact.GetMavenArtifactRequest, +): transport_class = transports.ArtifactRegistryRestTransport request_init = {} @@ -19091,7 +20395,7 @@ def test_get_file_rest_required_fields(request_type=file.GetFileRequest): unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_file._get_unset_required_fields(jsonified_request) + ).get_maven_artifact._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present @@ -19100,7 +20404,7 @@ def test_get_file_rest_required_fields(request_type=file.GetFileRequest): unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_file._get_unset_required_fields(jsonified_request) + ).get_maven_artifact._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone @@ -19114,7 +20418,7 @@ def test_get_file_rest_required_fields(request_type=file.GetFileRequest): request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = file.File() + return_value = artifact.MavenArtifact() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -19135,29 +20439,29 @@ def test_get_file_rest_required_fields(request_type=file.GetFileRequest): response_value.status_code = 200 # Convert return value to protobuf type - return_value = file.File.pb(return_value) + return_value = artifact.MavenArtifact.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_file(request) + response = client.get_maven_artifact(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_file_rest_unset_required_fields(): +def test_get_maven_artifact_rest_unset_required_fields(): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_file._get_unset_required_fields({}) + unset_fields = transport.get_maven_artifact._get_unset_required_fields({}) assert set(unset_fields) == (set(()) & set(("name",))) -def test_get_file_rest_flattened(): +def test_get_maven_artifact_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -19166,11 +20470,11 @@ def test_get_file_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = file.File() + return_value = artifact.MavenArtifact() # get arguments that satisfy an http rule for this method sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4" } # get truthy value for each flattened field @@ -19183,25 +20487,25 @@ def test_get_file_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = file.File.pb(return_value) + return_value = artifact.MavenArtifact.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_file(**mock_args) + client.get_maven_artifact(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/files/**}" + "%s/v1/{name=projects/*/locations/*/repositories/*/mavenArtifacts/*}" % client.transport._host, args[1], ) -def test_get_file_rest_flattened_error(transport: str = "rest"): +def test_get_maven_artifact_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -19210,13 +20514,13 @@ def test_get_file_rest_flattened_error(transport: str = "rest"): # 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_maven_artifact( + artifact.GetMavenArtifactRequest(), name="name_value", ) -def test_list_tags_rest_use_cached_wrapped_rpc(): +def test_list_npm_packages_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -19230,29 +20534,129 @@ def test_list_tags_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_tags in client._transport._wrapped_methods + assert client._transport.list_npm_packages in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_tags] = mock_rpc + client._transport._wrapped_methods[ + client._transport.list_npm_packages + ] = mock_rpc request = {} - client.list_tags(request) + client.list_npm_packages(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_tags(request) + client.list_npm_packages(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_tags_rest_flattened(): +def test_list_npm_packages_rest_required_fields( + request_type=artifact.ListNpmPackagesRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_npm_packages._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_npm_packages._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = artifact.ListNpmPackagesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.ListNpmPackagesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_npm_packages(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_npm_packages_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_npm_packages._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_npm_packages_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -19261,11 +20665,11 @@ def test_list_tags_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = tag.ListTagsResponse() + return_value = artifact.ListNpmPackagesResponse() # get arguments that satisfy an http rule for this method sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "parent": "projects/sample1/locations/sample2/repositories/sample3" } # get truthy value for each flattened field @@ -19278,25 +20682,25 @@ def test_list_tags_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = tag.ListTagsResponse.pb(return_value) + return_value = artifact.ListNpmPackagesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.list_tags(**mock_args) + client.list_npm_packages(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/tags" + "%s/v1/{parent=projects/*/locations/*/repositories/*}/npmPackages" % client.transport._host, args[1], ) -def test_list_tags_rest_flattened_error(transport: str = "rest"): +def test_list_npm_packages_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -19305,13 +20709,13 @@ def test_list_tags_rest_flattened_error(transport: str = "rest"): # 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(), + client.list_npm_packages( + artifact.ListNpmPackagesRequest(), parent="parent_value", ) -def test_list_tags_rest_pager(transport: str = "rest"): +def test_list_npm_packages_rest_pager(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -19323,28 +20727,28 @@ def test_list_tags_rest_pager(transport: str = "rest"): # with mock.patch.object(path_template, 'transcode') as transcode: # Set the response as a series of pages response = ( - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), - tag.Tag(), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), + artifact.NpmPackage(), ], next_page_token="abc", ), - tag.ListTagsResponse( - tags=[], + artifact.ListNpmPackagesResponse( + npm_packages=[], next_page_token="def", ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), ], next_page_token="ghi", ), - tag.ListTagsResponse( - tags=[ - tag.Tag(), - tag.Tag(), + artifact.ListNpmPackagesResponse( + npm_packages=[ + artifact.NpmPackage(), + artifact.NpmPackage(), ], ), ) @@ -19352,7 +20756,7 @@ def test_list_tags_rest_pager(transport: str = "rest"): response = response + response # Wrap the values into proper Response objs - response = tuple(tag.ListTagsResponse.to_json(x) for x in response) + response = tuple(artifact.ListNpmPackagesResponse.to_json(x) for x in response) return_values = tuple(Response() for i in response) for return_val, response_val in zip(return_values, response): return_val._content = response_val.encode("UTF-8") @@ -19360,21 +20764,21 @@ def test_list_tags_rest_pager(transport: str = "rest"): req.side_effect = return_values sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "parent": "projects/sample1/locations/sample2/repositories/sample3" } - pager = client.list_tags(request=sample_request) + pager = client.list_npm_packages(request=sample_request) results = list(pager) assert len(results) == 6 - assert all(isinstance(i, tag.Tag) for i in results) + assert all(isinstance(i, artifact.NpmPackage) for i in results) - pages = list(client.list_tags(request=sample_request).pages) + pages = list(client.list_npm_packages(request=sample_request).pages) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -def test_get_tag_rest_use_cached_wrapped_rpc(): +def test_get_npm_package_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -19388,124 +20792,112 @@ def test_get_tag_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_tag in client._transport._wrapped_methods + assert client._transport.get_npm_package in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_tag] = mock_rpc + client._transport._wrapped_methods[client._transport.get_npm_package] = mock_rpc request = {} - client.get_tag(request) + client.get_npm_package(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_tag(request) + client.get_npm_package(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +def test_get_npm_package_rest_required_fields( + request_type=artifact.GetNpmPackageRequest, +): + transport_class = transports.ArtifactRegistryRestTransport - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = tag.Tag() + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" - } + # verify fields with default values are dropped - # get truthy value for each flattened field - mock_args = dict( - name="name_value", - ) - mock_args.update(sample_request) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_npm_package._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # verify required fields with default values are now present - client.get_tag(**mock_args) + jsonified_request["name"] = "name_value" - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}" - % client.transport._host, - args[1], - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_npm_package._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -def test_get_tag_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) + request = request_type(**request_init) - # 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", - ) - + # Designate an appropriate value for the returned response. + return_value = artifact.NpmPackage() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result -def test_create_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + response_value = Response() + response_value.status_code = 200 - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # Convert return value to protobuf type + return_value = artifact.NpmPackage.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) - # Ensure method has been cached - assert client._transport.create_tag in client._transport._wrapped_methods + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.create_tag] = mock_rpc + response = client.get_npm_package(request) - request = {} - client.create_tag(request) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - client.create_tag(request) +def test_get_npm_package_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + unset_fields = transport.get_npm_package._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -def test_create_tag_rest_flattened(): +def test_get_npm_package_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -19514,18 +20906,16 @@ def test_create_tag_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag() + return_value = artifact.NpmPackage() # get arguments that satisfy an http rule for this method sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4" } # get truthy value for each flattened field mock_args = dict( - parent="parent_value", - tag=gda_tag.Tag(name="name_value"), - tag_id="tag_id_value", + name="name_value", ) mock_args.update(sample_request) @@ -19533,25 +20923,25 @@ def test_create_tag_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) + return_value = artifact.NpmPackage.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.create_tag(**mock_args) + client.get_npm_package(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/tags" + "%s/v1/{name=projects/*/locations/*/repositories/*/npmPackages/*}" % client.transport._host, args[1], ) -def test_create_tag_rest_flattened_error(transport: str = "rest"): +def test_get_npm_package_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -19560,15 +20950,13 @@ def test_create_tag_rest_flattened_error(transport: str = "rest"): # 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.get_npm_package( + artifact.GetNpmPackageRequest(), + name="name_value", ) -def test_update_tag_rest_use_cached_wrapped_rpc(): +def test_list_python_packages_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -19582,128 +20970,131 @@ def test_update_tag_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.update_tag in client._transport._wrapped_methods + assert ( + client._transport.list_python_packages in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.update_tag] = mock_rpc + client._transport._wrapped_methods[ + client._transport.list_python_packages + ] = mock_rpc request = {} - client.update_tag(request) + client.list_python_packages(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_tag(request) + client.list_python_packages(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_tag_rest_flattened(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +def test_list_python_packages_rest_required_fields( + request_type=artifact.ListPythonPackagesRequest, +): + transport_class = transports.ArtifactRegistryRestTransport - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag() + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) - # get arguments that satisfy an http rule for this method - sample_request = { - "tag": { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" - } - } + # verify fields with default values are dropped - # get truthy value for each flattened field - mock_args = dict( - tag=gda_tag.Tag(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - mock_args.update(sample_request) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_python_packages._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value + # verify required fields with default values are now present - client.update_tag(**mock_args) + jsonified_request["parent"] = "parent_value" - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{tag.name=projects/*/locations/*/repositories/*/packages/*/tags/*}" - % client.transport._host, - args[1], + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_python_packages._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", ) + ) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" -def test_update_tag_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) + request = request_type(**request_init) - # 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"]), - ) - + # Designate an appropriate value for the returned response. + return_value = artifact.ListPythonPackagesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result -def test_delete_tag_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + response_value = Response() + response_value.status_code = 200 - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + # Convert return value to protobuf type + return_value = artifact.ListPythonPackagesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) - # Ensure method has been cached - assert client._transport.delete_tag in client._transport._wrapped_methods + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[client._transport.delete_tag] = mock_rpc + response = client.list_python_packages(request) - request = {} - client.delete_tag(request) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - client.delete_tag(request) +def test_list_python_packages_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + unset_fields = transport.list_python_packages._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) -def test_delete_tag_rest_flattened(): +def test_list_python_packages_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -19712,40 +21103,42 @@ def test_delete_tag_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = artifact.ListPythonPackagesResponse() # get arguments that satisfy an http rule for this method sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + "parent": "projects/sample1/locations/sample2/repositories/sample3" } # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - json_return_value = "" + # Convert return value to protobuf type + return_value = artifact.ListPythonPackagesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.delete_tag(**mock_args) + client.list_python_packages(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}" + "%s/v1/{parent=projects/*/locations/*/repositories/*}/pythonPackages" % client.transport._host, args[1], ) -def test_delete_tag_rest_flattened_error(transport: str = "rest"): +def test_list_python_packages_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -19754,13 +21147,78 @@ def test_delete_tag_rest_flattened_error(transport: str = "rest"): # 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", + client.list_python_packages( + artifact.ListPythonPackagesRequest(), + parent="parent_value", ) -def test_set_iam_policy_rest_use_cached_wrapped_rpc(): +def test_list_python_packages_rest_pager(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + artifact.ListPythonPackagesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + pager = client.list_python_packages(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, artifact.PythonPackage) for i in results) + + pages = list(client.list_python_packages(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_python_package_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -19774,37 +21232,41 @@ def test_set_iam_policy_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.set_iam_policy in client._transport._wrapped_methods + assert ( + client._transport.get_python_package in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.set_iam_policy] = mock_rpc + client._transport._wrapped_methods[ + client._transport.get_python_package + ] = mock_rpc request = {} - client.set_iam_policy(request) + client.get_python_package(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.set_iam_policy(request) + client.get_python_package(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_set_iam_policy_rest_required_fields( - request_type=iam_policy_pb2.SetIamPolicyRequest, +def test_get_python_package_rest_required_fields( + request_type=artifact.GetPythonPackageRequest, ): transport_class = transports.ArtifactRegistryRestTransport request_init = {} - request_init["resource"] = "" + request_init["name"] = "" request = request_type(**request_init) - pb_request = request + pb_request = request_type.pb(request) jsonified_request = json.loads( json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) @@ -19813,21 +21275,21 @@ def test_set_iam_policy_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_iam_policy._get_unset_required_fields(jsonified_request) + ).get_python_package._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["resource"] = "resource_value" + jsonified_request["name"] = "name_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).set_iam_policy._get_unset_required_fields(jsonified_request) + ).get_python_package._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == "resource_value" + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), @@ -19836,7 +21298,7 @@ def test_set_iam_policy_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() + return_value = artifact.PythonPackage() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -19845,48 +21307,100 @@ def test_set_iam_policy_rest_required_fields( with mock.patch.object(path_template, "transcode") as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request + pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "post", + "method": "get", "query_params": pb_request, } - transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 + # Convert return value to protobuf type + return_value = artifact.PythonPackage.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.set_iam_policy(request) + response = client.get_python_package(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_set_iam_policy_rest_unset_required_fields(): +def test_get_python_package_rest_unset_required_fields(): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.set_iam_policy._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "resource", - "policy", - ) + unset_fields = transport.get_python_package._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_python_package_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = artifact.PythonPackage() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = artifact.PythonPackage.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_python_package(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/pythonPackages/*}" + % client.transport._host, + args[1], ) + + +def test_get_python_package_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_python_package( + artifact.GetPythonPackageRequest(), + name="name_value", + ) + -def test_get_iam_policy_rest_use_cached_wrapped_rpc(): +def test_import_apt_artifacts_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -19900,112 +21414,37 @@ def test_get_iam_policy_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_iam_policy in client._transport._wrapped_methods + assert ( + client._transport.import_apt_artifacts in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_iam_policy] = mock_rpc + client._transport._wrapped_methods[ + client._transport.import_apt_artifacts + ] = mock_rpc request = {} - client.get_iam_policy(request) + client.import_apt_artifacts(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_iam_policy(request) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.import_apt_artifacts(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_iam_policy_rest_required_fields( - request_type=iam_policy_pb2.GetIamPolicyRequest, -): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["resource"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_iam_policy._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = "resource_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_iam_policy._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("options",)) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == "resource_value" - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.get_iam_policy(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_get_iam_policy_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.get_iam_policy._get_unset_required_fields({}) - assert set(unset_fields) == (set(("options",)) & set(("resource",))) - - -def test_test_iam_permissions_rest_use_cached_wrapped_rpc(): +def test_import_yum_artifacts_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -20020,7 +21459,7 @@ def test_test_iam_permissions_rest_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.test_iam_permissions in client._transport._wrapped_methods + client._transport.import_yum_artifacts in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -20029,117 +21468,27 @@ def test_test_iam_permissions_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.test_iam_permissions + client._transport.import_yum_artifacts ] = mock_rpc request = {} - client.test_iam_permissions(request) + client.import_yum_artifacts(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.test_iam_permissions(request) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.import_yum_artifacts(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_test_iam_permissions_rest_required_fields( - request_type=iam_policy_pb2.TestIamPermissionsRequest, -): - transport_class = transports.ArtifactRegistryRestTransport - - request_init = {} - request_init["resource"] = "" - request_init["permissions"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).test_iam_permissions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = "resource_value" - jsonified_request["permissions"] = "permissions_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).test_iam_permissions._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == "resource_value" - assert "permissions" in jsonified_request - assert jsonified_request["permissions"] == "permissions_value" - - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - - response = client.test_iam_permissions(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_test_iam_permissions_rest_unset_required_fields(): - transport = transports.ArtifactRegistryRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.test_iam_permissions._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "resource", - "permissions", - ) - ) - ) - - -def test_get_project_settings_rest_use_cached_wrapped_rpc(): +def test_list_repositories_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -20153,9 +21502,7 @@ def test_get_project_settings_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.get_project_settings in client._transport._wrapped_methods - ) + assert client._transport.list_repositories in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -20163,29 +21510,29 @@ def test_get_project_settings_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.get_project_settings + client._transport.list_repositories ] = mock_rpc request = {} - client.get_project_settings(request) + client.list_repositories(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_project_settings(request) + client.list_repositories(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_project_settings_rest_required_fields( - request_type=settings.GetProjectSettingsRequest, +def test_list_repositories_rest_required_fields( + request_type=repository.ListRepositoriesRequest, ): transport_class = transports.ArtifactRegistryRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -20196,21 +21543,30 @@ def test_get_project_settings_rest_required_fields( unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_project_settings._get_unset_required_fields(jsonified_request) + ).list_repositories._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_project_settings._get_unset_required_fields(jsonified_request) + ).list_repositories._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), @@ -20219,7 +21575,7 @@ def test_get_project_settings_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() + return_value = repository.ListRepositoriesResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -20240,29 +21596,39 @@ def test_get_project_settings_rest_required_fields( response_value.status_code = 200 # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) + return_value = repository.ListRepositoriesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_project_settings(request) + response = client.list_repositories(request) expected_params = [("$alt", "json;enum-encoding=int")] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_project_settings_rest_unset_required_fields(): +def test_list_repositories_rest_unset_required_fields(): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_project_settings._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.list_repositories._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) -def test_get_project_settings_rest_flattened(): +def test_list_repositories_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -20271,14 +21637,14 @@ def test_get_project_settings_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() + return_value = repository.ListRepositoriesResponse() # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/projectSettings"} + sample_request = {"parent": "projects/sample1/locations/sample2"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", ) mock_args.update(sample_request) @@ -20286,23 +21652,25 @@ def test_get_project_settings_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) + return_value = repository.ListRepositoriesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_project_settings(**mock_args) + client.list_repositories(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/projectSettings}" % client.transport._host, args[1] + "%s/v1/{parent=projects/*/locations/*}/repositories" + % client.transport._host, + args[1], ) -def test_get_project_settings_rest_flattened_error(transport: str = "rest"): +def test_list_repositories_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -20311,54 +21679,195 @@ def test_get_project_settings_rest_flattened_error(transport: str = "rest"): # 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", - ) - - -def test_update_project_settings_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.update_project_settings - in client._transport._wrapped_methods - ) - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.list_repositories( + repository.ListRepositoriesRequest(), + parent="parent_value", ) - client._transport._wrapped_methods[ - client._transport.update_project_settings - ] = mock_rpc - request = {} - client.update_project_settings(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 +def test_list_repositories_rest_pager(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) - client.update_project_settings(request) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + repository.ListRepositoriesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_repositories(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, repository.Repository) for i in results) + + pages = list(client.list_repositories(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_repository_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_repository in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_repository] = mock_rpc + + request = {} + client.get_repository(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_repository(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_project_settings_rest_flattened(): +def test_get_repository_rest_required_fields( + request_type=repository.GetRepositoryRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = repository.Repository() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = repository.Repository.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_repository(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_repository_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_repository._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_repository_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -20367,17 +21876,16 @@ def test_update_project_settings_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings() + return_value = repository.Repository() # get arguments that satisfy an http rule for this method sample_request = { - "project_settings": {"name": "projects/sample1/projectSettings"} + "name": "projects/sample1/locations/sample2/repositories/sample3" } # get truthy value for each flattened field mock_args = dict( - project_settings=settings.ProjectSettings(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + name="name_value", ) mock_args.update(sample_request) @@ -20385,25 +21893,25 @@ def test_update_project_settings_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) + return_value = repository.Repository.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_project_settings(**mock_args) + client.get_repository(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{project_settings.name=projects/*/projectSettings}" + "%s/v1/{name=projects/*/locations/*/repositories/*}" % client.transport._host, args[1], ) -def test_update_project_settings_rest_flattened_error(transport: str = "rest"): +def test_get_repository_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -20412,14 +21920,13 @@ def test_update_project_settings_rest_flattened_error(transport: str = "rest"): # 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"]), + client.get_repository( + repository.GetRepositoryRequest(), + name="name_value", ) -def test_get_vpcsc_config_rest_use_cached_wrapped_rpc(): +def test_create_repository_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -20433,7 +21940,7 @@ def test_get_vpcsc_config_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_vpcsc_config in client._transport._wrapped_methods + assert client._transport.create_repository in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -20441,29 +21948,34 @@ def test_get_vpcsc_config_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.get_vpcsc_config + client._transport.create_repository ] = mock_rpc request = {} - client.get_vpcsc_config(request) + client.create_repository(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_vpcsc_config(request) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_repository(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_vpcsc_config_rest_required_fields( - request_type=vpcsc_config.GetVPCSCConfigRequest, +def test_create_repository_rest_required_fields( + request_type=gda_repository.CreateRepositoryRequest, ): transport_class = transports.ArtifactRegistryRestTransport request_init = {} - request_init["name"] = "" + request_init["parent"] = "" + request_init["repository_id"] = "" request = request_type(**request_init) pb_request = request_type.pb(request) jsonified_request = json.loads( @@ -20471,24 +21983,32 @@ def test_get_vpcsc_config_rest_required_fields( ) # verify fields with default values are dropped + assert "repositoryId" not in jsonified_request unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_vpcsc_config._get_unset_required_fields(jsonified_request) + ).create_repository._get_unset_required_fields(jsonified_request) jsonified_request.update(unset_fields) # verify required fields with default values are now present + assert "repositoryId" in jsonified_request + assert jsonified_request["repositoryId"] == request_init["repository_id"] - jsonified_request["name"] = "name_value" + jsonified_request["parent"] = "parent_value" + jsonified_request["repositoryId"] = "repository_id_value" unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ).get_vpcsc_config._get_unset_required_fields(jsonified_request) + ).create_repository._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("repository_id",)) jsonified_request.update(unset_fields) # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "repositoryId" in jsonified_request + assert jsonified_request["repositoryId"] == "repository_id_value" client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), @@ -20497,7 +22017,7 @@ def test_get_vpcsc_config_rest_required_fields( request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = vpcsc_config.VPCSCConfig() + return_value = operations_pb2.Operation(name="operations/spam") # Mock the http request call within the method and fake a response. with mock.patch.object(Session, "request") as req: # We need to mock transcode() because providing default values @@ -20509,38 +22029,51 @@ def test_get_vpcsc_config_rest_required_fields( pb_request = request_type.pb(request) transcode_result = { "uri": "v1/sample_method", - "method": "get", + "method": "post", "query_params": pb_request, } + transcode_result["body"] = pb_request transcode.return_value = transcode_result response_value = Response() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = vpcsc_config.VPCSCConfig.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_vpcsc_config(request) + response = client.create_repository(request) - expected_params = [("$alt", "json;enum-encoding=int")] + expected_params = [ + ( + "repositoryId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] actual_params = req.call_args.kwargs["params"] assert expected_params == actual_params -def test_get_vpcsc_config_rest_unset_required_fields(): +def test_create_repository_rest_unset_required_fields(): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials ) - unset_fields = transport.get_vpcsc_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + unset_fields = transport.create_repository._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("repositoryId",)) + & set( + ( + "parent", + "repositoryId", + "repository", + ) + ) + ) -def test_get_vpcsc_config_rest_flattened(): +def test_create_repository_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -20549,39 +22082,44 @@ def test_get_vpcsc_config_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = vpcsc_config.VPCSCConfig() + return_value = operations_pb2.Operation(name="operations/spam") # get arguments that satisfy an http rule for this method - sample_request = {"name": "projects/sample1/locations/sample2/vpcscConfig"} + sample_request = {"parent": "projects/sample1/locations/sample2"} # get truthy value for each flattened field mock_args = dict( - name="name_value", + parent="parent_value", + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), + repository_id="repository_id_value", ) mock_args.update(sample_request) # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = vpcsc_config.VPCSCConfig.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.get_vpcsc_config(**mock_args) + client.create_repository(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/vpcscConfig}" % client.transport._host, + "%s/v1/{parent=projects/*/locations/*}/repositories" + % client.transport._host, args[1], ) -def test_get_vpcsc_config_rest_flattened_error(transport: str = "rest"): +def test_create_repository_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -20590,13 +22128,19 @@ def test_get_vpcsc_config_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_vpcsc_config( - vpcsc_config.GetVPCSCConfigRequest(), - name="name_value", + 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", ) -def test_update_vpcsc_config_rest_use_cached_wrapped_rpc(): +def test_update_repository_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -20610,9 +22154,7 @@ def test_update_vpcsc_config_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.update_vpcsc_config in client._transport._wrapped_methods - ) + assert client._transport.update_repository in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -20620,23 +22162,23 @@ def test_update_vpcsc_config_rest_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.update_vpcsc_config + client._transport.update_repository ] = mock_rpc request = {} - client.update_vpcsc_config(request) + client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.update_vpcsc_config(request) + client.update_repository(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_update_vpcsc_config_rest_flattened(): +def test_update_repository_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -20645,16 +22187,22 @@ def test_update_vpcsc_config_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gda_vpcsc_config.VPCSCConfig() + return_value = gda_repository.Repository() # get arguments that satisfy an http rule for this method sample_request = { - "vpcsc_config": {"name": "projects/sample1/locations/sample2/vpcscConfig"} + "repository": { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } } # get truthy value for each flattened field mock_args = dict( - vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), + repository=gda_repository.Repository( + maven_config=gda_repository.Repository.MavenRepositoryConfig( + allow_snapshot_overwrites=True + ) + ), update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) mock_args.update(sample_request) @@ -20663,25 +22211,25 @@ def test_update_vpcsc_config_rest_flattened(): response_value = Response() response_value.status_code = 200 # Convert return value to protobuf type - return_value = gda_vpcsc_config.VPCSCConfig.pb(return_value) + return_value = gda_repository.Repository.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value - client.update_vpcsc_config(**mock_args) + client.update_repository(**mock_args) # Establish that the underlying call was made with the expected # request object values. assert len(req.mock_calls) == 1 _, args, _ = req.mock_calls[0] assert path_template.validate( - "%s/v1/{vpcsc_config.name=projects/*/locations/*/vpcscConfig}" + "%s/v1/{repository.name=projects/*/locations/*/repositories/*}" % client.transport._host, args[1], ) -def test_update_vpcsc_config_rest_flattened_error(transport: str = "rest"): +def test_update_repository_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -20690,1967 +22238,9431 @@ def test_update_vpcsc_config_rest_flattened_error(transport: str = "rest"): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_vpcsc_config( - gda_vpcsc_config.UpdateVPCSCConfigRequest(), - vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), + 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"]), ) -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): +def test_delete_repository_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, + transport="rest", ) - # It is an error to provide an api_key and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options=options, - transport=transport, - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) + # Ensure method has been cached + assert client._transport.delete_repository in client._transport._wrapped_methods - # It is an error to provide scopes and a transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = ArtifactRegistryClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) + client._transport._wrapped_methods[ + client._transport.delete_repository + ] = mock_rpc + request = {} + client.delete_repository(request) -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = ArtifactRegistryClient(transport=transport) - assert client.transport is transport - - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.ArtifactRegistryGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.ArtifactRegistryGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() -@pytest.mark.parametrize( - "transport_class", - [ - transports.ArtifactRegistryGrpcTransport, - transports.ArtifactRegistryGrpcAsyncIOTransport, - transports.ArtifactRegistryRestTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() + client.delete_repository(request) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -def test_transport_kind_grpc(): - transport = ArtifactRegistryClient.get_transport_class("grpc")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" +def test_delete_repository_rest_required_fields( + request_type=repository.DeleteRepositoryRequest, +): + transport_class = transports.ArtifactRegistryRestTransport -def test_initialize_client_w_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc" + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - assert client is not None + # verify fields with default values are dropped -# 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_docker_images_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), "__call__" - ) as call: - call.return_value = artifact.ListDockerImagesResponse() - client.list_docker_images(request=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListDockerImagesRequest() + jsonified_request["name"] = "name_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -# 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_get_docker_image_empty_call_grpc(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_docker_image), "__call__") as call: - call.return_value = artifact.DockerImage() - client.get_docker_image(request=None) + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetDockerImageRequest() + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) - assert args[0] == request_msg + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_repository(request) -# 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_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_maven_artifacts), "__call__" - ) as call: - call.return_value = artifact.ListMavenArtifactsResponse() - client.list_maven_artifacts(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListMavenArtifactsRequest() +def test_delete_repository_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) - assert args[0] == request_msg + unset_fields = transport.delete_repository._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -# 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_get_maven_artifact_empty_call_grpc(): +def test_delete_repository_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_maven_artifact), "__call__" - ) as call: - call.return_value = artifact.MavenArtifact() - client.get_maven_artifact(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetMavenArtifactRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } -# 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_npm_packages_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_npm_packages), "__call__" - ) as call: - call.return_value = artifact.ListNpmPackagesResponse() - client.list_npm_packages(request=None) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListNpmPackagesRequest() + client.delete_repository(**mock_args) - assert args[0] == request_msg + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*}" + % client.transport._host, + args[1], + ) -# 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_get_npm_package_empty_call_grpc(): +def test_delete_repository_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: - call.return_value = artifact.NpmPackage() - client.get_npm_package(request=None) + # 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", + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetNpmPackageRequest() - assert args[0] == request_msg +def test_list_packages_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# 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_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert client._transport.list_packages in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), "__call__" - ) as call: - call.return_value = artifact.ListPythonPackagesResponse() - client.list_python_packages(request=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_packages] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListPythonPackagesRequest() + request = {} + client.list_packages(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.list_packages(request) -# 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_get_python_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_python_package), "__call__" - ) as call: - call.return_value = artifact.PythonPackage() - client.get_python_package(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetPythonPackageRequest() +def test_list_packages_rest_required_fields(request_type=package.ListPackagesRequest): + transport_class = transports.ArtifactRegistryRestTransport - assert args[0] == request_msg + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped -# 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_import_apt_artifacts_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_packages._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, and fake the 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=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = apt_artifact.ImportAptArtifactsRequest() + jsonified_request["parent"] = "parent_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_packages._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" -# 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_import_yum_artifacts_empty_call_grpc(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, 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=None) + # Designate an appropriate value for the returned response. + return_value = package.ListPackagesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = yum_artifact.ImportYumArtifactsRequest() + response_value = Response() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = package.ListPackagesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value -# 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_repositories_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + response = client.list_packages(request) - # Mock the actual call, 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=None) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.ListRepositoriesRequest() - assert args[0] == request_msg +def test_list_packages_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_packages._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) -# 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_get_repository_empty_call_grpc(): +def test_list_packages_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.GetRepositoryRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = package.ListPackagesResponse() + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } -# 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_create_repository_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) - # Mock the actual call, 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=None) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = package.ListPackagesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.CreateRepositoryRequest() + client.list_packages(**mock_args) - assert args[0] == request_msg + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/packages" + % client.transport._host, + args[1], + ) -# 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_update_repository_empty_call_grpc(): +def test_list_packages_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.UpdateRepositoryRequest() - - assert args[0] == request_msg + # 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", + ) -# 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_delete_repository_empty_call_grpc(): +def test_list_packages_rest_pager(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, 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=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), + ) + # Two responses for two calls + response = response + response - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.DeleteRepositoryRequest() + # Wrap the values into proper Response objs + response = tuple(package.ListPackagesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values - assert args[0] == request_msg + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + pager = client.list_packages(request=sample_request) -# 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_packages_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, package.Package) for i in results) - # Mock the actual call, 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=None) + pages = list(client.list_packages(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.ListPackagesRequest() - assert args[0] == request_msg +def test_get_package_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# 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_get_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert client._transport.get_package in client._transport._wrapped_methods - # Mock the actual call, 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=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_package] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.GetPackageRequest() + request = {} + client.get_package(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.get_package(request) -# 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_delete_package_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Mock the actual call, 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=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.DeletePackageRequest() +def test_get_package_rest_required_fields(request_type=package.GetPackageRequest): + transport_class = transports.ArtifactRegistryRestTransport - assert args[0] == request_msg + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped -# 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_versions_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_package._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Mock the actual call, 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=None) + # verify required fields with default values are now present - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.ListVersionsRequest() + jsonified_request["name"] = "name_value" - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_package._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -# 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_get_version_empty_call_grpc(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, 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=None) + # Designate an appropriate value for the returned response. + return_value = package.Package() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.GetVersionRequest() + response_value = Response() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = package.Package.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value -# 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_delete_version_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + response = client.get_package(request) - # Mock the actual call, 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=None) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.DeleteVersionRequest() - assert args[0] == request_msg +def test_get_package_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_package._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -# 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_batch_delete_versions_empty_call_grpc(): +def test_get_package_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.batch_delete_versions(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.BatchDeleteVersionsRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = package.Package() + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } -# 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_files_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) - # Mock the actual call, 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=None) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = package.Package.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.ListFilesRequest() + client.get_package(**mock_args) - assert args[0] == request_msg + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*}" + % client.transport._host, + args[1], + ) -# 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_get_file_empty_call_grpc(): +def test_get_package_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.GetFileRequest() + # 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", + ) - assert args[0] == request_msg +def test_delete_package_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) -# 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_tags_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # Mock the actual call, 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=None) + # Ensure method has been cached + assert client._transport.delete_package in client._transport._wrapped_methods - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.ListTagsRequest() + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_package] = mock_rpc - assert args[0] == request_msg + request = {} + client.delete_package(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -# 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_get_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # Mock the actual call, 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=None) + client.delete_package(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.GetTagRequest() + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - assert args[0] == request_msg +def test_delete_package_rest_required_fields(request_type=package.DeletePackageRequest): + transport_class = transports.ArtifactRegistryRestTransport -# 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_create_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, 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=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.CreateTagRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_package._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_package._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" -# 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_update_tag_empty_call_grpc(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, 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=None) + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.UpdateTagRequest() + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) - assert args[0] == request_msg + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_package(request) -# 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_delete_tag_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: - call.return_value = None - client.delete_tag(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.DeleteTagRequest() +def test_delete_package_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) - assert args[0] == request_msg + unset_fields = transport.delete_package._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -# 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_set_iam_policy_empty_call_grpc(): +def test_delete_package_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } -# 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_get_iam_policy_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) - # Mock the actual call, 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=None) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() + client.delete_package(**mock_args) - assert args[0] == request_msg + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*}" + % client.transport._host, + args[1], + ) -# 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_test_iam_permissions_empty_call_grpc(): +def test_delete_package_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, 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=None) + # 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", + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() - assert args[0] == request_msg +def test_list_versions_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# 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_get_project_settings_empty_call_grpc(): - client = ArtifactRegistryClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert client._transport.list_versions in client._transport._wrapped_methods - # Mock the actual call, 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=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_versions] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.GetProjectSettingsRequest() + request = {} + client.list_versions(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.list_versions(request) -# 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_update_project_settings_empty_call_grpc(): + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_versions_rest_flattened(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_project_settings), "__call__" - ) as call: - call.return_value = settings.ProjectSettings() - client.update_project_settings(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = version.ListVersionsResponse() - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.UpdateProjectSettingsRequest() + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } - assert args[0] == request_msg + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = version.ListVersionsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value -# 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_get_vpcsc_config_empty_call_grpc(): + client.list_versions(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/versions" + % client.transport._host, + args[1], + ) + + +def test_list_versions_rest_flattened_error(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the 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=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = vpcsc_config.GetVPCSCConfigRequest() - - assert args[0] == request_msg + # 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", + ) -# 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_update_vpcsc_config_empty_call_grpc(): +def test_list_versions_rest_pager(transport: str = "rest"): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_vpcsc_config), "__call__" - ) as call: - call.return_value = gda_vpcsc_config.VPCSCConfig() - client.update_vpcsc_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_vpcsc_config.UpdateVPCSCConfigRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), + ) + # Two responses for two calls + response = response + response + # Wrap the values into proper Response objs + response = tuple(version.ListVersionsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values -def test_transport_kind_grpc_asyncio(): - transport = ArtifactRegistryAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } + pager = client.list_versions(request=sample_request) -def test_initialize_client_w_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), transport="grpc_asyncio" - ) - assert client is not None + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, version.Version) for i in results) + pages = list(client.list_versions(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_docker_images_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_docker_images), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - artifact.ListDockerImagesResponse( - next_page_token="next_page_token_value", - ) +def test_get_version_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - await client.list_docker_images(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListDockerImagesRequest() + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - assert args[0] == request_msg + # Ensure method has been cached + assert client._transport.get_version in client._transport._wrapped_methods + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_version] = mock_rpc -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_docker_image_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + request = {} + client.get_version(request) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_docker_image), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - artifact.DockerImage( - name="name_value", - uri="uri_value", - tags=["tags_value"], - image_size_bytes=1699, - media_type="media_type_value", - ) - ) - await client.get_docker_image(request=None) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetDockerImageRequest() + client.get_version(request) - assert args[0] == request_msg + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_maven_artifacts_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_version_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_maven_artifacts), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - artifact.ListMavenArtifactsResponse( - next_page_token="next_page_token_value", - ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = version.Version() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", ) - await client.list_maven_artifacts(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListMavenArtifactsRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = version.Version.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.get_version(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_maven_artifact_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_version_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( - artifact.MavenArtifact( - name="name_value", - pom_uri="pom_uri_value", - group_id="group_id_value", - artifact_id="artifact_id_value", - version="version_value", - ) + # 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", ) - await client.get_maven_artifact(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetMavenArtifactRequest() - assert args[0] == request_msg +def test_delete_version_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_npm_packages_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert client._transport.delete_version in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - 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( - artifact.ListNpmPackagesResponse( - next_page_token="next_page_token_value", - ) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) - await client.list_npm_packages(request=None) + client._transport._wrapped_methods[client._transport.delete_version] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListNpmPackagesRequest() + request = {} + client.delete_version(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_npm_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + client.delete_version(request) - # Mock the actual call, and fake the request. - 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( - artifact.NpmPackage( - name="name_value", - package_name="package_name_value", - version="version_value", - tags=["tags_value"], - ) - ) - await client.get_npm_package(request=None) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetNpmPackageRequest() - assert args[0] == request_msg +def test_delete_version_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_python_packages_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_python_packages), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - artifact.ListPythonPackagesResponse( - next_page_token="next_page_token_value", - ) + # get truthy value for each flattened field + mock_args = dict( + name="name_value", ) - await client.list_python_packages(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.ListPythonPackagesRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.delete_version(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/versions/*}" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_python_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_delete_version_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, 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", - ) + # 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(), + name="name_value", ) - await client.get_python_package(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = artifact.GetPythonPackageRequest() - assert args[0] == request_msg +def test_batch_delete_versions_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_import_apt_artifacts_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - 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( - operations_pb2.Operation(name="operations/spam") + # Ensure method has been cached + assert ( + client._transport.batch_delete_versions + in client._transport._wrapped_methods ) - await client.import_apt_artifacts(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = apt_artifact.ImportAptArtifactsRequest() + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.batch_delete_versions + ] = mock_rpc - assert args[0] == request_msg + request = {} + client.batch_delete_versions(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_import_yum_artifacts_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.import_yum_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") - ) - await client.import_yum_artifacts(request=None) + client.batch_delete_versions(request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = yum_artifact.ImportYumArtifactsRequest() + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - assert args[0] == request_msg +def test_batch_delete_versions_rest_required_fields( + request_type=version.BatchDeleteVersionsRequest, +): + transport_class = transports.ArtifactRegistryRestTransport -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_repositories_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + request_init = {} + request_init["names"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( - repository.ListRepositoriesResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_repositories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.ListRepositoriesRequest() + # verify fields with default values are dropped - assert args[0] == request_msg + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_delete_versions._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with default values are now present -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + jsonified_request["names"] = "names_value" - # Mock the actual call, 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", - mode=repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - ) - ) - await client.get_repository(request=None) + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_delete_versions._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.GetRepositoryRequest() + # verify required fields with non-default values are left alone + assert "names" in jsonified_request + assert jsonified_request["names"] == "names_value" - assert args[0] == request_msg + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) - # Mock the actual call, 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") - ) - await client.create_repository(request=None) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.CreateRepositoryRequest() + response = client.batch_delete_versions(request) - assert args[0] == request_msg + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_batch_delete_versions_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, 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", - mode=gda_repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - ) - ) - await client.update_repository(request=None) + unset_fields = transport.batch_delete_versions._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("names",))) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_repository.UpdateRepositoryRequest() - assert args[0] == request_msg +def test_batch_delete_versions_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_repository_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } - # Mock the actual call, 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") + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + names=["names_value"], ) - await client.delete_repository(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = repository.DeleteRepositoryRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.batch_delete_versions(**mock_args) + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/versions:batchDelete" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_packages_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +def test_batch_delete_versions_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, 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", - ) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.batch_delete_versions( + version.BatchDeleteVersionsRequest(), + parent="parent_value", + names=["names_value"], ) - await client.list_packages(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.ListPackagesRequest() - assert args[0] == request_msg +def test_update_version_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert client._transport.update_version in client._transport._wrapped_methods - # Mock the actual call, 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", - ) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) - await client.get_package(request=None) + client._transport._wrapped_methods[client._transport.update_version] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.GetPackageRequest() + request = {} + client.update_version(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.update_version(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_package_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_version_rest_required_fields( + request_type=gda_version.UpdateVersionRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, 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") - ) - await client.delete_package(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = package.DeletePackageRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_version._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_version._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + # verify required fields with non-default values are left alone -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_versions_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_versions), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - version.ListVersionsResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_versions(request=None) + # Designate an appropriate value for the returned response. + return_value = gda_version.Version() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.ListVersionsRequest() + response_value = Response() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = gda_version.Version.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_version_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + response = client.update_version(request) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_version), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - version.Version( - name="name_value", - description="description_value", - ) - ) - await client.get_version(request=None) + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.GetVersionRequest() - assert args[0] == request_msg +def test_update_version_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + unset_fields = transport.update_version._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("version",))) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_version_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +def test_update_version_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_version), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = gda_version.Version() + + # get arguments that satisfy an http rule for this method + sample_request = { + "version": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } + } + + # get truthy value for each flattened field + mock_args = dict( + version=gda_version.Version(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - await client.delete_version(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.DeleteVersionRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = gda_version.Version.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.update_version(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{version.name=projects/*/locations/*/repositories/*/packages/*/versions/*}" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_batch_delete_versions_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_update_version_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.batch_delete_versions), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_version( + gda_version.UpdateVersionRequest(), + version=gda_version.Version(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) - await client.batch_delete_versions(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = version.BatchDeleteVersionsRequest() - assert args[0] == request_msg +def test_list_files_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_files_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Ensure method has been cached + assert client._transport.list_files in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_files), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - file.ListFilesResponse( - next_page_token="next_page_token_value", - ) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) - await client.list_files(request=None) + client._transport._wrapped_methods[client._transport.list_files] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.ListFilesRequest() + request = {} + client.list_files(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + client.list_files(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_file_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_files_rest_required_fields(request_type=file.ListFilesRequest): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_file), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - file.File( - name="name_value", - size_bytes=1089, - owner="owner_value", - ) - ) - await client.get_file(request=None) + # verify fields with default values are dropped - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = file.GetFileRequest() + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_files._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) - assert args[0] == request_msg + # verify required fields with default values are now present + jsonified_request["parent"] = "parent_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_tags_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_files._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) ) + jsonified_request.update(unset_fields) - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( - tag.ListTagsResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_tags(request=None) + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.ListTagsRequest() + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) - assert args[0] == request_msg + # Designate an appropriate value for the returned response. + return_value = file.ListFilesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = file.ListFilesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_files(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_files_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_tag), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - tag.Tag( - name="name_value", - version="version_value", + unset_fields = transport.list_files._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", ) ) - await client.get_tag(request=None) + & set(("parent",)) + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.GetTagRequest() - assert args[0] == request_msg +def test_list_files_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = file.ListFilesResponse() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( - gda_tag.Tag( - name="name_value", - version="version_value", - ) + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", ) - await client.create_tag(request=None) + mock_args.update(sample_request) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.CreateTagRequest() + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = file.ListFilesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value - assert args[0] == request_msg + client.list_files(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/files" + % client.transport._host, + args[1], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_files_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( - gda_tag.Tag( - name="name_value", - version="version_value", - ) + # 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(), + parent="parent_value", ) - await client.update_tag(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_tag.UpdateTagRequest() - assert args[0] == request_msg +def test_list_files_rest_pager(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), + ) + # Two responses for two calls + response = response + response -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_tag_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Wrap the values into proper Response objs + response = tuple(file.ListFilesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_tag(request=None) + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = tag.DeleteTagRequest() + pager = client.list_files(request=sample_request) - assert args[0] == request_msg + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, file.File) for i in results) + pages = list(client.list_files(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_set_iam_policy_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) +def test_get_file_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - await client.set_iam_policy(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - assert args[0] == request_msg + # Ensure method has been cached + assert client._transport.get_file in client._transport._wrapped_methods + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_file] = mock_rpc -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_iam_policy_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + request = {} + client.get_file(request) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) - ) - await client.get_iam_policy(request=None) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() + client.get_file(request) - assert args[0] == request_msg + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_test_iam_permissions_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_file_rest_required_fields(request_type=file.GetFileRequest): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_file._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_file._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = file.File() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = file.File.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_file(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_file_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_file._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_file_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = file.File() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = file.File.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_file(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/files/**}" + % client.transport._host, + args[1], + ) + + +def test_get_file_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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(), + name="name_value", + ) + + +def test_delete_file_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_file in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_file] = mock_rpc + + request = {} + client.delete_file(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_file(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_file_rest_required_fields(request_type=file.DeleteFileRequest): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_file._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_file._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_file(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_file_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_file._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_file_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_file(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/files/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_file_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_file( + file.DeleteFileRequest(), + name="name_value", + ) + + +def test_update_file_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_file in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_file] = mock_rpc + + request = {} + client.update_file(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_file(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_file_rest_required_fields(request_type=gda_file.UpdateFileRequest): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_file._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_file._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = gda_file.File() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = gda_file.File.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_file(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_file_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_file._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "file", + "updateMask", + ) + ) + ) + + +def test_update_file_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = gda_file.File() + + # get arguments that satisfy an http rule for this method + sample_request = { + "file": { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + file=gda_file.File(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = gda_file.File.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_file(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{file.name=projects/*/locations/*/repositories/*/files/*}" + % client.transport._host, + args[1], + ) + + +def test_update_file_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_file( + gda_file.UpdateFileRequest(), + file=gda_file.File(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_list_tags_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_tags in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_tags] = mock_rpc + + request = {} + client.list_tags(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_tags(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_tags_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tag.ListTagsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = tag.ListTagsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_tags(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/tags" + % client.transport._host, + args[1], + ) + + +def test_list_tags_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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", + ) + + +def test_list_tags_rest_pager(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + 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(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(tag.ListTagsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } + + pager = client.list_tags(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, tag.Tag) for i in results) + + pages = list(client.list_tags(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_tag_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_tag in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_tag] = mock_rpc + + request = {} + client.get_tag(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_tag(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_tag_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tag.Tag() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = tag.Tag.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_tag(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}" + % client.transport._host, + args[1], + ) + + +def test_get_tag_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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", + ) + + +def test_create_tag_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_tag in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_tag] = mock_rpc + + request = {} + client.create_tag(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_tag(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_tag_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = gda_tag.Tag() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + tag=gda_tag.Tag(name="name_value"), + tag_id="tag_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = gda_tag.Tag.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_tag(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/packages/*}/tags" + % client.transport._host, + args[1], + ) + + +def test_create_tag_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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", + ) + + +def test_update_tag_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_tag in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_tag] = mock_rpc + + request = {} + client.update_tag(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_tag(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_tag_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = gda_tag.Tag() + + # get arguments that satisfy an http rule for this method + sample_request = { + "tag": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + } + } + + # get truthy value for each flattened field + mock_args = dict( + tag=gda_tag.Tag(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = gda_tag.Tag.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_tag(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{tag.name=projects/*/locations/*/repositories/*/packages/*/tags/*}" + % client.transport._host, + args[1], + ) + + +def test_update_tag_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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"]), + ) + + +def test_delete_tag_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_tag in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_tag] = mock_rpc + + request = {} + client.delete_tag(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_tag(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_tag_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_tag(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/packages/*/tags/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_tag_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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", + ) + + +def test_create_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_rule in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_rule] = mock_rpc + + request = {} + client.create_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_rule_rest_required_fields(request_type=gda_rule.CreateRuleRequest): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_rule._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("rule_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = gda_rule.Rule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = gda_rule.Rule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_rule_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(("ruleId",)) & set(("parent",))) + + +def test_create_rule_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = gda_rule.Rule() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + rule=gda_rule.Rule(name="name_value"), + rule_id="rule_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = gda_rule.Rule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/rules" + % client.transport._host, + args[1], + ) + + +def test_create_rule_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_rule( + gda_rule.CreateRuleRequest(), + parent="parent_value", + rule=gda_rule.Rule(name="name_value"), + rule_id="rule_id_value", + ) + + +def test_list_rules_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_rules in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_rules] = mock_rpc + + request = {} + client.list_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_rules(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_rules_rest_required_fields(request_type=rule.ListRulesRequest): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_rules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_rules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = rule.ListRulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = rule.ListRulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_rules(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_rules_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_rules._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_rules_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = rule.ListRulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = rule.ListRulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_rules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/rules" + % client.transport._host, + args[1], + ) + + +def test_list_rules_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_rules( + rule.ListRulesRequest(), + parent="parent_value", + ) + + +def test_list_rules_rest_pager(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + rule.Rule(), + ], + next_page_token="abc", + ), + rule.ListRulesResponse( + rules=[], + next_page_token="def", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + ], + next_page_token="ghi", + ), + rule.ListRulesResponse( + rules=[ + rule.Rule(), + rule.Rule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(rule.ListRulesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + pager = client.list_rules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, rule.Rule) for i in results) + + pages = list(client.list_rules(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_rule in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_rule] = mock_rpc + + request = {} + client.get_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_rule_rest_required_fields(request_type=rule.GetRuleRequest): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = rule.Rule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = rule.Rule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_rule_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_rule_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = rule.Rule() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = rule.Rule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/rules/*}" + % client.transport._host, + args[1], + ) + + +def test_get_rule_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_rule( + rule.GetRuleRequest(), + name="name_value", + ) + + +def test_update_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_rule in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_rule] = mock_rpc + + request = {} + client.update_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_rule_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = gda_rule.Rule() + + # get arguments that satisfy an http rule for this method + sample_request = { + "rule": { + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + rule=gda_rule.Rule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = gda_rule.Rule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{rule.name=projects/*/locations/*/repositories/*/rules/*}" + % client.transport._host, + args[1], + ) + + +def test_update_rule_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_rule( + gda_rule.UpdateRuleRequest(), + rule=gda_rule.Rule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_rule in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_rule] = mock_rpc + + request = {} + client.delete_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.delete_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_rule_rest_required_fields(request_type=rule.DeleteRuleRequest): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_rule_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_rule_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/rules/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_rule_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_rule( + rule.DeleteRuleRequest(), + name="name_value", + ) + + +def test_set_iam_policy_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.set_iam_policy in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.set_iam_policy] = mock_rpc + + request = {} + client.set_iam_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.set_iam_policy(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_set_iam_policy_rest_required_fields( + request_type=iam_policy_pb2.SetIamPolicyRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["resource"] = "" + request = request_type(**request_init) + pb_request = request + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).set_iam_policy._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["resource"] = "resource_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).set_iam_policy._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "resource" in jsonified_request + assert jsonified_request["resource"] == "resource_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.set_iam_policy(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_set_iam_policy_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.set_iam_policy._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "resource", + "policy", + ) + ) + ) + + +def test_get_iam_policy_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_iam_policy in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_iam_policy] = mock_rpc + + request = {} + client.get_iam_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_iam_policy(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_iam_policy_rest_required_fields( + request_type=iam_policy_pb2.GetIamPolicyRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["resource"] = "" + request = request_type(**request_init) + pb_request = request + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_iam_policy._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["resource"] = "resource_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_iam_policy._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("options",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "resource" in jsonified_request + assert jsonified_request["resource"] == "resource_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_iam_policy(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_iam_policy_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_iam_policy._get_unset_required_fields({}) + assert set(unset_fields) == (set(("options",)) & set(("resource",))) + + +def test_test_iam_permissions_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.test_iam_permissions in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.test_iam_permissions + ] = mock_rpc + + request = {} + client.test_iam_permissions(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.test_iam_permissions(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_test_iam_permissions_rest_required_fields( + request_type=iam_policy_pb2.TestIamPermissionsRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["resource"] = "" + request_init["permissions"] = "" + request = request_type(**request_init) + pb_request = request + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).test_iam_permissions._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["resource"] = "resource_value" + jsonified_request["permissions"] = "permissions_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).test_iam_permissions._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "resource" in jsonified_request + assert jsonified_request["resource"] == "resource_value" + assert "permissions" in jsonified_request + assert jsonified_request["permissions"] == "permissions_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = iam_policy_pb2.TestIamPermissionsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.test_iam_permissions(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_test_iam_permissions_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.test_iam_permissions._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "resource", + "permissions", + ) + ) + ) + + +def test_get_project_settings_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_project_settings in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_project_settings + ] = mock_rpc + + request = {} + client.get_project_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_project_settings(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_project_settings_rest_required_fields( + request_type=settings.GetProjectSettingsRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_project_settings._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_project_settings._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = settings.ProjectSettings() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = settings.ProjectSettings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_project_settings(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_project_settings_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_project_settings._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_project_settings_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = settings.ProjectSettings() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/projectSettings"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = settings.ProjectSettings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_project_settings(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/projectSettings}" % client.transport._host, args[1] + ) + + +def test_get_project_settings_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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", + ) + + +def test_update_project_settings_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_project_settings + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_project_settings + ] = mock_rpc + + request = {} + client.update_project_settings(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_project_settings(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_project_settings_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = settings.ProjectSettings() + + # get arguments that satisfy an http rule for this method + sample_request = { + "project_settings": {"name": "projects/sample1/projectSettings"} + } + + # get truthy value for each flattened field + mock_args = dict( + project_settings=settings.ProjectSettings(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = settings.ProjectSettings.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_project_settings(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{project_settings.name=projects/*/projectSettings}" + % client.transport._host, + args[1], + ) + + +def test_update_project_settings_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # 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"]), + ) + + +def test_get_vpcsc_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vpcsc_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_vpcsc_config + ] = mock_rpc + + request = {} + client.get_vpcsc_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vpcsc_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vpcsc_config_rest_required_fields( + request_type=vpcsc_config.GetVPCSCConfigRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vpcsc_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vpcsc_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = vpcsc_config.VPCSCConfig() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = vpcsc_config.VPCSCConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_vpcsc_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_vpcsc_config_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_vpcsc_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_vpcsc_config_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = vpcsc_config.VPCSCConfig() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/vpcscConfig"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = vpcsc_config.VPCSCConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_vpcsc_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/vpcscConfig}" % client.transport._host, + args[1], + ) + + +def test_get_vpcsc_config_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vpcsc_config( + vpcsc_config.GetVPCSCConfigRequest(), + name="name_value", + ) + + +def test_update_vpcsc_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_vpcsc_config in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_vpcsc_config + ] = mock_rpc + + request = {} + client.update_vpcsc_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_vpcsc_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_vpcsc_config_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = gda_vpcsc_config.VPCSCConfig() + + # get arguments that satisfy an http rule for this method + sample_request = { + "vpcsc_config": {"name": "projects/sample1/locations/sample2/vpcscConfig"} + } + + # get truthy value for each flattened field + mock_args = dict( + vpcsc_config=gda_vpcsc_config.VPCSCConfig(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = gda_vpcsc_config.VPCSCConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_vpcsc_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{vpcsc_config.name=projects/*/locations/*/vpcscConfig}" + % client.transport._host, + args[1], + ) + + +def test_update_vpcsc_config_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + 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"]), + ) + + +def test_update_package_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_package in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_package] = mock_rpc + + request = {} + client.update_package(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.update_package(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_package_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = gda_package.Package() + + # get arguments that satisfy an http rule for this method + sample_request = { + "package": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + package=gda_package.Package(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = gda_package.Package.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_package(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{package.name=projects/*/locations/*/repositories/*/packages/*}" + % client.transport._host, + args[1], + ) + + +def test_update_package_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_package( + gda_package.UpdatePackageRequest(), + package=gda_package.Package(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_list_attachments_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_attachments in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_attachments + ] = mock_rpc + + request = {} + client.list_attachments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_attachments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_attachments_rest_required_fields( + request_type=attachment.ListAttachmentsRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_attachments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_attachments._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = attachment.ListAttachmentsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = attachment.ListAttachmentsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_attachments(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_attachments_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_attachments._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_attachments_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = attachment.ListAttachmentsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = attachment.ListAttachmentsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_attachments(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/attachments" + % client.transport._host, + args[1], + ) + + +def test_list_attachments_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_attachments( + attachment.ListAttachmentsRequest(), + parent="parent_value", + ) + + +def test_list_attachments_rest_pager(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + attachment.Attachment(), + ], + next_page_token="abc", + ), + attachment.ListAttachmentsResponse( + attachments=[], + next_page_token="def", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + ], + next_page_token="ghi", + ), + attachment.ListAttachmentsResponse( + attachments=[ + attachment.Attachment(), + attachment.Attachment(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + attachment.ListAttachmentsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + pager = client.list_attachments(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, attachment.Attachment) for i in results) + + pages = list(client.list_attachments(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_attachment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_attachment in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_attachment] = mock_rpc + + request = {} + client.get_attachment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_attachment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_attachment_rest_required_fields( + request_type=attachment.GetAttachmentRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_attachment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_attachment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = attachment.Attachment() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = attachment.Attachment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_attachment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_attachment_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_attachment._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_attachment_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = attachment.Attachment() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/attachments/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = attachment.Attachment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_attachment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/attachments/*}" + % client.transport._host, + args[1], + ) + + +def test_get_attachment_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_attachment( + attachment.GetAttachmentRequest(), + name="name_value", + ) + + +def test_create_attachment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_attachment in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_attachment + ] = mock_rpc + + request = {} + client.create_attachment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_attachment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_attachment_rest_required_fields( + request_type=gda_attachment.CreateAttachmentRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["attachment_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "attachmentId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_attachment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "attachmentId" in jsonified_request + assert jsonified_request["attachmentId"] == request_init["attachment_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["attachmentId"] = "attachment_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_attachment._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("attachment_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "attachmentId" in jsonified_request + assert jsonified_request["attachmentId"] == "attachment_id_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_attachment(request) + + expected_params = [ + ( + "attachmentId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_attachment_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_attachment._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("attachmentId",)) + & set( + ( + "parent", + "attachmentId", + "attachment", + ) + ) + ) + + +def test_create_attachment_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + attachment=gda_attachment.Attachment(name="name_value"), + attachment_id="attachment_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_attachment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/attachments" + % client.transport._host, + args[1], + ) + + +def test_create_attachment_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_attachment( + gda_attachment.CreateAttachmentRequest(), + parent="parent_value", + attachment=gda_attachment.Attachment(name="name_value"), + attachment_id="attachment_id_value", + ) + + +def test_delete_attachment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_attachment in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_attachment + ] = mock_rpc + + request = {} + client.delete_attachment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_attachment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_attachment_rest_required_fields( + request_type=attachment.DeleteAttachmentRequest, +): + transport_class = transports.ArtifactRegistryRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_attachment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_attachment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_attachment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_attachment_rest_unset_required_fields(): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_attachment._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_attachment_rest_flattened(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/attachments/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_attachment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/attachments/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_attachment_rest_flattened_error(transport: str = "rest"): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_attachment( + attachment.DeleteAttachmentRequest(), + name="name_value", + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.ArtifactRegistryGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.ArtifactRegistryGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ArtifactRegistryClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.ArtifactRegistryGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ArtifactRegistryClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ArtifactRegistryClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.ArtifactRegistryGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = ArtifactRegistryClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.ArtifactRegistryGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = ArtifactRegistryClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.ArtifactRegistryGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.ArtifactRegistryGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ArtifactRegistryGrpcTransport, + transports.ArtifactRegistryGrpcAsyncIOTransport, + transports.ArtifactRegistryRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_kind_grpc(): + transport = ArtifactRegistryClient.get_transport_class("grpc")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "grpc" + + +def test_initialize_client_w_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc" + ) + assert client is not None + + +# 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_docker_images_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_docker_images), "__call__" + ) as call: + call.return_value = artifact.ListDockerImagesResponse() + client.list_docker_images(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.ListDockerImagesRequest() + + assert args[0] == request_msg + + +# 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_get_docker_image_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_docker_image), "__call__") as call: + call.return_value = artifact.DockerImage() + client.get_docker_image(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.GetDockerImageRequest() + + assert args[0] == request_msg + + +# 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_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_maven_artifacts), "__call__" + ) as call: + call.return_value = artifact.ListMavenArtifactsResponse() + client.list_maven_artifacts(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.ListMavenArtifactsRequest() + + assert args[0] == request_msg + + +# 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_get_maven_artifact_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_maven_artifact), "__call__" + ) as call: + call.return_value = artifact.MavenArtifact() + client.get_maven_artifact(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.GetMavenArtifactRequest() + + assert args[0] == request_msg + + +# 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_npm_packages_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_npm_packages), "__call__" + ) as call: + call.return_value = artifact.ListNpmPackagesResponse() + client.list_npm_packages(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.ListNpmPackagesRequest() + + assert args[0] == request_msg + + +# 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_get_npm_package_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_npm_package), "__call__") as call: + call.return_value = artifact.NpmPackage() + client.get_npm_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.GetNpmPackageRequest() + + assert args[0] == request_msg + + +# 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_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_python_packages), "__call__" + ) as call: + call.return_value = artifact.ListPythonPackagesResponse() + client.list_python_packages(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.ListPythonPackagesRequest() + + assert args[0] == request_msg + + +# 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_get_python_package_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_python_package), "__call__" + ) as call: + call.return_value = artifact.PythonPackage() + client.get_python_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.GetPythonPackageRequest() + + assert args[0] == request_msg + + +# 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_import_apt_artifacts_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = apt_artifact.ImportAptArtifactsRequest() + + assert args[0] == request_msg + + +# 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_import_yum_artifacts_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = yum_artifact.ImportYumArtifactsRequest() + + assert args[0] == request_msg + + +# 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_repositories_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = repository.ListRepositoriesRequest() + + assert args[0] == request_msg + + +# 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_get_repository_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = repository.GetRepositoryRequest() + + assert args[0] == request_msg + + +# 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_create_repository_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_repository.CreateRepositoryRequest() + + assert args[0] == request_msg + + +# 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_update_repository_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_repository.UpdateRepositoryRequest() + + assert args[0] == request_msg + + +# 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_delete_repository_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = repository.DeleteRepositoryRequest() + + assert args[0] == request_msg + + +# 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_packages_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = package.ListPackagesRequest() + + assert args[0] == request_msg + + +# 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_get_package_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = package.GetPackageRequest() + + assert args[0] == request_msg + + +# 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_delete_package_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = package.DeletePackageRequest() + + assert args[0] == request_msg + + +# 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_versions_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = version.ListVersionsRequest() + + assert args[0] == request_msg + + +# 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_get_version_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = version.GetVersionRequest() + + assert args[0] == request_msg + + +# 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_delete_version_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = version.DeleteVersionRequest() + + assert args[0] == request_msg + + +# 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_batch_delete_versions_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_versions), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.batch_delete_versions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = version.BatchDeleteVersionsRequest() + + assert args[0] == request_msg + + +# 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_update_version_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_version), "__call__") as call: + call.return_value = gda_version.Version() + client.update_version(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_version.UpdateVersionRequest() + + assert args[0] == request_msg + + +# 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_files_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = file.ListFilesRequest() + + assert args[0] == request_msg + + +# 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_get_file_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = file.GetFileRequest() + + assert args[0] == request_msg + + +# 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_delete_file_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_file), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_file(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = file.DeleteFileRequest() + + assert args[0] == request_msg + + +# 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_update_file_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_file), "__call__") as call: + call.return_value = gda_file.File() + client.update_file(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_file.UpdateFileRequest() + + assert args[0] == request_msg + + +# 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_tags_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = tag.ListTagsRequest() + + assert args[0] == request_msg + + +# 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_get_tag_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = tag.GetTagRequest() + + assert args[0] == request_msg + + +# 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_create_tag_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_tag.CreateTagRequest() + + assert args[0] == request_msg + + +# 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_update_tag_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_tag.UpdateTagRequest() + + assert args[0] == request_msg + + +# 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_delete_tag_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_tag), "__call__") as call: + call.return_value = None + client.delete_tag(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = tag.DeleteTagRequest() + + assert args[0] == request_msg + + +# 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_create_rule_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_rule), "__call__") as call: + call.return_value = gda_rule.Rule() + client.create_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_rule.CreateRuleRequest() + + assert args[0] == request_msg + + +# 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_rules_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_rules), "__call__") as call: + call.return_value = rule.ListRulesResponse() + client.list_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.ListRulesRequest() + + assert args[0] == request_msg + + +# 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_get_rule_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: + call.return_value = rule.Rule() + client.get_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.GetRuleRequest() + + assert args[0] == request_msg + + +# 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_update_rule_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: + call.return_value = gda_rule.Rule() + client.update_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_rule.UpdateRuleRequest() + + assert args[0] == request_msg + + +# 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_delete_rule_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: + call.return_value = None + client.delete_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.DeleteRuleRequest() + + assert args[0] == request_msg + + +# 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_set_iam_policy_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.SetIamPolicyRequest() + + assert args[0] == request_msg + + +# 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_get_iam_policy_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.GetIamPolicyRequest() + + assert args[0] == request_msg + + +# 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_test_iam_permissions_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.TestIamPermissionsRequest() + + assert args[0] == request_msg + + +# 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_get_project_settings_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = settings.GetProjectSettingsRequest() + + assert args[0] == request_msg + + +# 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_update_project_settings_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_project_settings), "__call__" + ) as call: + call.return_value = settings.ProjectSettings() + client.update_project_settings(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = settings.UpdateProjectSettingsRequest() + + assert args[0] == request_msg + + +# 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_get_vpcsc_config_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the 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=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = vpcsc_config.GetVPCSCConfigRequest() + + assert args[0] == request_msg + + +# 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_update_vpcsc_config_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_vpcsc_config), "__call__" + ) as call: + call.return_value = gda_vpcsc_config.VPCSCConfig() + client.update_vpcsc_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_vpcsc_config.UpdateVPCSCConfigRequest() + + assert args[0] == request_msg + + +# 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_update_package_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + call.return_value = gda_package.Package() + client.update_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_package.UpdatePackageRequest() + + assert args[0] == request_msg + + +# 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_attachments_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + call.return_value = attachment.ListAttachmentsResponse() + client.list_attachments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.ListAttachmentsRequest() + + assert args[0] == request_msg + + +# 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_get_attachment_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_attachment), "__call__") as call: + call.return_value = attachment.Attachment() + client.get_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.GetAttachmentRequest() + + assert args[0] == request_msg + + +# 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_create_attachment_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_attachment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_attachment.CreateAttachmentRequest() + + assert args[0] == request_msg + + +# 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_delete_attachment_empty_call_grpc(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.DeleteAttachmentRequest() + + assert args[0] == request_msg + + +def test_transport_kind_grpc_asyncio(): + transport = ArtifactRegistryAsyncClient.get_transport_class("grpc_asyncio")( + credentials=async_anonymous_credentials() + ) + assert transport.kind == "grpc_asyncio" + + +def test_initialize_client_w_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), transport="grpc_asyncio" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_docker_images_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_docker_images), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + artifact.ListDockerImagesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_docker_images(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.ListDockerImagesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_docker_image_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_docker_image), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + artifact.DockerImage( + name="name_value", + uri="uri_value", + tags=["tags_value"], + image_size_bytes=1699, + media_type="media_type_value", + ) + ) + await client.get_docker_image(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.GetDockerImageRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_maven_artifacts_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_maven_artifacts), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + artifact.ListMavenArtifactsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_maven_artifacts(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.ListMavenArtifactsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_maven_artifact_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( + artifact.MavenArtifact( + name="name_value", + pom_uri="pom_uri_value", + group_id="group_id_value", + artifact_id="artifact_id_value", + version="version_value", + ) + ) + await client.get_maven_artifact(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.GetMavenArtifactRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_npm_packages_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + 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( + artifact.ListNpmPackagesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_npm_packages(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.ListNpmPackagesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_npm_package_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + 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( + artifact.NpmPackage( + name="name_value", + package_name="package_name_value", + version="version_value", + tags=["tags_value"], + ) + ) + await client.get_npm_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.GetNpmPackageRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_python_packages_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_python_packages), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + artifact.ListPythonPackagesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_python_packages(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.ListPythonPackagesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_python_package_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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", + ) + ) + await client.get_python_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = artifact.GetPythonPackageRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_import_apt_artifacts_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + 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( + operations_pb2.Operation(name="operations/spam") + ) + await client.import_apt_artifacts(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = apt_artifact.ImportAptArtifactsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_import_yum_artifacts_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.import_yum_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") + ) + await client.import_yum_artifacts(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = yum_artifact.ImportYumArtifactsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_repositories_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( + repository.ListRepositoriesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_repositories(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = repository.ListRepositoriesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_repository_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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", + mode=repository.Repository.Mode.STANDARD_REPOSITORY, + size_bytes=1089, + satisfies_pzs=True, + cleanup_policy_dry_run=True, + disallow_unspecified_mode=True, + satisfies_pzi=True, + ) + ) + await client.get_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = repository.GetRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_repository_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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") + ) + await client.create_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_repository.CreateRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_repository_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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", + mode=gda_repository.Repository.Mode.STANDARD_REPOSITORY, + size_bytes=1089, + satisfies_pzs=True, + cleanup_policy_dry_run=True, + disallow_unspecified_mode=True, + satisfies_pzi=True, + ) + ) + await client.update_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_repository.UpdateRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_repository_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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") + ) + await client.delete_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = repository.DeleteRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_packages_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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", + ) + ) + await client.list_packages(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = package.ListPackagesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_package_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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", + ) + ) + await client.get_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = package.GetPackageRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_package_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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") + ) + await client.delete_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = package.DeletePackageRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_versions_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_versions), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + version.ListVersionsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_versions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = version.ListVersionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_version_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_version), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + version.Version( + name="name_value", + description="description_value", + ) + ) + await client.get_version(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = version.GetVersionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_version_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_version), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_version(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = version.DeleteVersionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_batch_delete_versions_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.batch_delete_versions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.batch_delete_versions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = version.BatchDeleteVersionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_version_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_version), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_version.Version( + name="name_value", + description="description_value", + ) + ) + await client.update_version(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_version.UpdateVersionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_files_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_files), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + file.ListFilesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_files(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = file.ListFilesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_file_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_file), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + file.File( + name="name_value", + size_bytes=1089, + owner="owner_value", + ) + ) + await client.get_file(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = file.GetFileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_file_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_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") + ) + await client.delete_file(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = file.DeleteFileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_file_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_file), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_file.File( + name="name_value", + size_bytes=1089, + owner="owner_value", + ) + ) + await client.update_file(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_file.UpdateFileRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_tags_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( + tag.ListTagsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_tags(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = tag.ListTagsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_tag_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_tag), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + tag.Tag( + name="name_value", + version="version_value", + ) + ) + await client.get_tag(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = tag.GetTagRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_tag_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( + gda_tag.Tag( + name="name_value", + version="version_value", + ) + ) + await client.create_tag(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_tag.CreateTagRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_tag_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( + gda_tag.Tag( + name="name_value", + version="version_value", + ) + ) + await client.update_tag(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_tag.UpdateTagRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_tag_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_tag(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = tag.DeleteTagRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_rule_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_rule.Rule( + name="name_value", + action=gda_rule.Rule.Action.ALLOW, + operation=gda_rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", + ) + ) + await client.create_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_rule.CreateRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_rules_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_rules), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + rule.ListRulesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.ListRulesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_rule_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + rule.Rule( + name="name_value", + action=rule.Rule.Action.ALLOW, + operation=rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", + ) + ) + await client.get_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.GetRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_rule_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_rule.Rule( + name="name_value", + action=gda_rule.Rule.Action.ALLOW, + operation=gda_rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", + ) + ) + await client.update_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_rule.UpdateRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_rule_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.DeleteRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_set_iam_policy_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + ) + await client.set_iam_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.SetIamPolicyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_iam_policy_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + ) + await client.get_iam_policy(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.GetIamPolicyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_test_iam_permissions_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) + ) + await client.test_iam_permissions(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.TestIamPermissionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_project_settings_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( + settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + pull_percent=1293, + ) + ) + await client.get_project_settings(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = settings.GetProjectSettingsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_project_settings_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( + settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + pull_percent=1293, + ) + ) + await client.update_project_settings(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = settings.UpdateProjectSettingsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vpcsc_config_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + 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( + vpcsc_config.VPCSCConfig( + name="name_value", + vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, + ) + ) + await client.get_vpcsc_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = vpcsc_config.GetVPCSCConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_vpcsc_config_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_vpcsc_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_vpcsc_config.VPCSCConfig( + name="name_value", + vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, + ) + ) + await client.update_vpcsc_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_vpcsc_config.UpdateVPCSCConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_package_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gda_package.Package( + name="name_value", + display_name="display_name_value", + ) + ) + await client.update_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_package.UpdatePackageRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_attachments_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + attachment.ListAttachmentsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_attachments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.ListAttachmentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_attachment_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_attachment), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + attachment.Attachment( + name="name_value", + target="target_value", + type_="type__value", + attachment_namespace="attachment_namespace_value", + files=["files_value"], + oci_version_name="oci_version_name_value", + ) + ) + await client.get_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.GetAttachmentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_attachment_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_attachment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_attachment.CreateAttachmentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_attachment_empty_call_grpc_asyncio(): + client = ArtifactRegistryAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.DeleteAttachmentRequest() + + assert args[0] == request_msg + + +def test_transport_kind_rest(): + transport = ArtifactRegistryClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_list_docker_images_rest_bad_request( + request_type=artifact.ListDockerImagesRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_docker_images(request) + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.ListDockerImagesRequest, + dict, + ], +) +def test_list_docker_images_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = artifact.ListDockerImagesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.ListDockerImagesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_docker_images(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDockerImagesPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_docker_images_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_list_docker_images" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_list_docker_images" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = artifact.ListDockerImagesRequest.pb( + artifact.ListDockerImagesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = artifact.ListDockerImagesResponse.to_json( + artifact.ListDockerImagesResponse() + ) + req.return_value.content = return_value + + request = artifact.ListDockerImagesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = artifact.ListDockerImagesResponse() + + client.list_docker_images( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_docker_image_rest_bad_request(request_type=artifact.GetDockerImageRequest): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_docker_image(request) + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.GetDockerImageRequest, + dict, + ], +) +def test_get_docker_image_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = artifact.DockerImage( + name="name_value", + uri="uri_value", + tags=["tags_value"], + image_size_bytes=1699, + media_type="media_type_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.DockerImage.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_docker_image(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, artifact.DockerImage) + assert response.name == "name_value" + assert response.uri == "uri_value" + assert response.tags == ["tags_value"] + assert response.image_size_bytes == 1699 + assert response.media_type == "media_type_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_docker_image_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_get_docker_image" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_get_docker_image" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = artifact.GetDockerImageRequest.pb(artifact.GetDockerImageRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = artifact.DockerImage.to_json(artifact.DockerImage()) + req.return_value.content = return_value + + request = artifact.GetDockerImageRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = artifact.DockerImage() + + client.get_docker_image( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_maven_artifacts_rest_bad_request( + request_type=artifact.ListMavenArtifactsRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_maven_artifacts(request) + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.ListMavenArtifactsRequest, + dict, + ], +) +def test_list_maven_artifacts_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = artifact.ListMavenArtifactsResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.ListMavenArtifactsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_maven_artifacts(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListMavenArtifactsPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_maven_artifacts_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_list_maven_artifacts" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_list_maven_artifacts" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = artifact.ListMavenArtifactsRequest.pb( + artifact.ListMavenArtifactsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = artifact.ListMavenArtifactsResponse.to_json( + artifact.ListMavenArtifactsResponse() + ) + req.return_value.content = return_value + + request = artifact.ListMavenArtifactsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = artifact.ListMavenArtifactsResponse() + + client.list_maven_artifacts( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_maven_artifact_rest_bad_request( + request_type=artifact.GetMavenArtifactRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_maven_artifact(request) + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.GetMavenArtifactRequest, + dict, + ], +) +def test_get_maven_artifact_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + 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", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.MavenArtifact.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_maven_artifact(request) + + # 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" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_maven_artifact_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_get_maven_artifact" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_get_maven_artifact" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = artifact.GetMavenArtifactRequest.pb( + artifact.GetMavenArtifactRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = artifact.MavenArtifact.to_json(artifact.MavenArtifact()) + req.return_value.content = return_value + + request = artifact.GetMavenArtifactRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = artifact.MavenArtifact() + + client.get_maven_artifact( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_npm_packages_rest_bad_request( + request_type=artifact.ListNpmPackagesRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_npm_packages(request) + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.ListNpmPackagesRequest, + dict, + ], +) +def test_list_npm_packages_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = artifact.ListNpmPackagesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.ListNpmPackagesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_npm_packages(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListNpmPackagesPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_npm_packages_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_list_npm_packages" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_list_npm_packages" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = artifact.ListNpmPackagesRequest.pb( + artifact.ListNpmPackagesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = artifact.ListNpmPackagesResponse.to_json( + artifact.ListNpmPackagesResponse() + ) + req.return_value.content = return_value + + request = artifact.ListNpmPackagesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = artifact.ListNpmPackagesResponse() + + client.list_npm_packages( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_npm_package_rest_bad_request(request_type=artifact.GetNpmPackageRequest): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_npm_package(request) + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.GetNpmPackageRequest, + dict, + ], +) +def test_get_npm_package_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = artifact.NpmPackage( + name="name_value", + package_name="package_name_value", + version="version_value", + tags=["tags_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.NpmPackage.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_npm_package(request) + + # Establish that the response is the type that we expect. + 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.parametrize("null_interceptor", [True, False]) +def test_get_npm_package_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_get_npm_package" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_get_npm_package" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = artifact.GetNpmPackageRequest.pb(artifact.GetNpmPackageRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = artifact.NpmPackage.to_json(artifact.NpmPackage()) + req.return_value.content = return_value + + request = artifact.GetNpmPackageRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = artifact.NpmPackage() + + client.get_npm_package( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_python_packages_rest_bad_request( + request_type=artifact.ListPythonPackagesRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.list_python_packages(request) + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.ListPythonPackagesRequest, + dict, + ], +) +def test_list_python_packages_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = artifact.ListPythonPackagesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.ListPythonPackagesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_python_packages(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPythonPackagesPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_python_packages_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_list_python_packages" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_list_python_packages" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = artifact.ListPythonPackagesRequest.pb( + artifact.ListPythonPackagesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = artifact.ListPythonPackagesResponse.to_json( + artifact.ListPythonPackagesResponse() + ) + req.return_value.content = return_value + + request = artifact.ListPythonPackagesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = artifact.ListPythonPackagesResponse() + + client.list_python_packages( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_python_package_rest_bad_request( + request_type=artifact.GetPythonPackageRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_python_package(request) + + +@pytest.mark.parametrize( + "request_type", + [ + artifact.GetPythonPackageRequest, + dict, + ], +) +def test_get_python_package_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = artifact.PythonPackage( + name="name_value", + uri="uri_value", + package_name="package_name_value", + version="version_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = artifact.PythonPackage.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_python_package(request) + + # 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.parametrize("null_interceptor", [True, False]) +def test_get_python_package_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_get_python_package" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_get_python_package" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = artifact.GetPythonPackageRequest.pb( + artifact.GetPythonPackageRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = artifact.PythonPackage.to_json(artifact.PythonPackage()) + req.return_value.content = return_value + + request = artifact.GetPythonPackageRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = artifact.PythonPackage() + + client.get_python_package( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_import_apt_artifacts_rest_bad_request( + request_type=apt_artifact.ImportAptArtifactsRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.import_apt_artifacts(request) + + +@pytest.mark.parametrize( + "request_type", + [ + apt_artifact.ImportAptArtifactsRequest, + dict, + ], +) +def test_import_apt_artifacts_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], - ) - ) - await client.test_iam_permissions(request=None) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.import_apt_artifacts(request) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_project_settings_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_import_apt_artifacts_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), ) + client = ArtifactRegistryClient(transport=transport) - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings( - name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - ) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_import_apt_artifacts" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_import_apt_artifacts" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = apt_artifact.ImportAptArtifactsRequest.pb( + apt_artifact.ImportAptArtifactsRequest() ) - await client.get_project_settings(request=None) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.GetProjectSettingsRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = apt_artifact.ImportAptArtifactsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + client.import_apt_artifacts( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_project_settings_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + pre.assert_called_once() + post.assert_called_once() - # Mock the actual call, 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 = grpc_helpers_async.FakeUnaryUnaryCall( - settings.ProjectSettings( - name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, - ) - ) - await client.update_project_settings(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = settings.UpdateProjectSettingsRequest() +def test_import_yum_artifacts_rest_bad_request( + request_type=yum_artifact.ImportYumArtifactsRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.import_yum_artifacts(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vpcsc_config_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +@pytest.mark.parametrize( + "request_type", + [ + yum_artifact.ImportYumArtifactsRequest, + dict, + ], +) +def test_import_yum_artifacts_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - 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( - vpcsc_config.VPCSCConfig( - name="name_value", - vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) - ) - await client.get_vpcsc_config(request=None) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = vpcsc_config.GetVPCSCConfigRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.import_yum_artifacts(request) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_vpcsc_config_empty_call_grpc_asyncio(): - client = ArtifactRegistryAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_import_yum_artifacts_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), ) + client = ArtifactRegistryClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.update_vpcsc_config), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gda_vpcsc_config.VPCSCConfig( - name="name_value", - vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_import_yum_artifacts" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_import_yum_artifacts" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = yum_artifact.ImportYumArtifactsRequest.pb( + yum_artifact.ImportYumArtifactsRequest() ) - await client.update_vpcsc_config(request=None) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = gda_vpcsc_config.UpdateVPCSCConfigRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = yum_artifact.ImportYumArtifactsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + client.import_yum_artifacts( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -def test_transport_kind_rest(): - transport = ArtifactRegistryClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" + pre.assert_called_once() + post.assert_called_once() -def test_list_docker_images_rest_bad_request( - request_type=artifact.ListDockerImagesRequest, +def test_list_repositories_rest_bad_request( + request_type=repository.ListRepositoriesRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22664,29 +31676,29 @@ def test_list_docker_images_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_docker_images(request) + client.list_repositories(request) @pytest.mark.parametrize( "request_type", [ - artifact.ListDockerImagesRequest, + repository.ListRepositoriesRequest, dict, ], ) -def test_list_docker_images_rest_call_success(request_type): +def test_list_repositories_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = artifact.ListDockerImagesResponse( + return_value = repository.ListRepositoriesResponse( next_page_token="next_page_token_value", ) @@ -22695,19 +31707,19 @@ def test_list_docker_images_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = artifact.ListDockerImagesResponse.pb(return_value) + return_value = repository.ListRepositoriesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_docker_images(request) + response = client.list_repositories(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDockerImagesPager) + assert isinstance(response, pagers.ListRepositoriesPager) assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_docker_images_rest_interceptors(null_interceptor): +def test_list_repositories_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -22721,14 +31733,14 @@ def test_list_docker_images_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_docker_images" + transports.ArtifactRegistryRestInterceptor, "post_list_repositories" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_docker_images" + transports.ArtifactRegistryRestInterceptor, "pre_list_repositories" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = artifact.ListDockerImagesRequest.pb( - artifact.ListDockerImagesRequest() + pb_message = repository.ListRepositoriesRequest.pb( + repository.ListRepositoriesRequest() ) transcode.return_value = { "method": "post", @@ -22739,20 +31751,20 @@ def test_list_docker_images_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = artifact.ListDockerImagesResponse.to_json( - artifact.ListDockerImagesResponse() + return_value = repository.ListRepositoriesResponse.to_json( + repository.ListRepositoriesResponse() ) req.return_value.content = return_value - request = artifact.ListDockerImagesRequest() + request = repository.ListRepositoriesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = artifact.ListDockerImagesResponse() + post.return_value = repository.ListRepositoriesResponse() - client.list_docker_images( + client.list_repositories( request, metadata=[ ("key", "val"), @@ -22764,14 +31776,12 @@ def test_list_docker_images_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_docker_image_rest_bad_request(request_type=artifact.GetDockerImageRequest): +def test_get_repository_rest_bad_request(request_type=repository.GetRepositoryRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4" - } + request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22785,36 +31795,39 @@ def test_get_docker_image_rest_bad_request(request_type=artifact.GetDockerImageR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_docker_image(request) + client.get_repository(request) @pytest.mark.parametrize( "request_type", [ - artifact.GetDockerImageRequest, + repository.GetRepositoryRequest, dict, ], ) -def test_get_docker_image_rest_call_success(request_type): +def test_get_repository_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/dockerImages/sample4" - } + request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = artifact.DockerImage( + return_value = repository.Repository( name="name_value", - uri="uri_value", - tags=["tags_value"], - image_size_bytes=1699, - media_type="media_type_value", + format_=repository.Repository.Format.DOCKER, + description="description_value", + kms_key_name="kms_key_name_value", + mode=repository.Repository.Mode.STANDARD_REPOSITORY, + size_bytes=1089, + satisfies_pzs=True, + cleanup_policy_dry_run=True, + disallow_unspecified_mode=True, + satisfies_pzi=True, ) # Wrap the value into a proper Response obj @@ -22822,23 +31835,28 @@ def test_get_docker_image_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = artifact.DockerImage.pb(return_value) + return_value = repository.Repository.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_docker_image(request) + response = client.get_repository(request) # Establish that the response is the type that we expect. - assert isinstance(response, artifact.DockerImage) + assert isinstance(response, repository.Repository) assert response.name == "name_value" - assert response.uri == "uri_value" - assert response.tags == ["tags_value"] - assert response.image_size_bytes == 1699 - assert response.media_type == "media_type_value" + assert response.format_ == repository.Repository.Format.DOCKER + assert response.description == "description_value" + assert response.kms_key_name == "kms_key_name_value" + assert response.mode == repository.Repository.Mode.STANDARD_REPOSITORY + assert response.size_bytes == 1089 + assert response.satisfies_pzs is True + assert response.cleanup_policy_dry_run is True + assert response.disallow_unspecified_mode is True + assert response.satisfies_pzi is True @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_docker_image_rest_interceptors(null_interceptor): +def test_get_repository_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -22852,13 +31870,15 @@ def test_get_docker_image_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_docker_image" + transports.ArtifactRegistryRestInterceptor, "post_get_repository" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_docker_image" + transports.ArtifactRegistryRestInterceptor, "pre_get_repository" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = artifact.GetDockerImageRequest.pb(artifact.GetDockerImageRequest()) + pb_message = repository.GetRepositoryRequest.pb( + repository.GetRepositoryRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -22868,18 +31888,18 @@ def test_get_docker_image_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = artifact.DockerImage.to_json(artifact.DockerImage()) + return_value = repository.Repository.to_json(repository.Repository()) req.return_value.content = return_value - request = artifact.GetDockerImageRequest() + request = repository.GetRepositoryRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = artifact.DockerImage() + post.return_value = repository.Repository() - client.get_docker_image( + client.get_repository( request, metadata=[ ("key", "val"), @@ -22891,14 +31911,14 @@ def test_get_docker_image_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_maven_artifacts_rest_bad_request( - request_type=artifact.ListMavenArtifactsRequest, +def test_create_repository_rest_bad_request( + request_type=gda_repository.CreateRepositoryRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22912,50 +31932,181 @@ def test_list_maven_artifacts_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_maven_artifacts(request) + client.create_repository(request) @pytest.mark.parametrize( "request_type", [ - artifact.ListMavenArtifactsRequest, + gda_repository.CreateRepositoryRequest, dict, ], ) -def test_list_maven_artifacts_rest_call_success(request_type): +def test_create_repository_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["repository"] = { + "maven_config": {"allow_snapshot_overwrites": True, "version_policy": 1}, + "docker_config": {"immutable_tags": True}, + "virtual_repository_config": { + "upstream_policies": [ + {"id": "id_value", "repository": "repository_value", "priority": 898} + ] + }, + "remote_repository_config": { + "docker_repository": { + "public_repository": 1, + "custom_repository": {"uri": "uri_value"}, + }, + "maven_repository": { + "public_repository": 1, + "custom_repository": {"uri": "uri_value"}, + }, + "npm_repository": { + "public_repository": 1, + "custom_repository": {"uri": "uri_value"}, + }, + "python_repository": { + "public_repository": 1, + "custom_repository": {"uri": "uri_value"}, + }, + "apt_repository": { + "public_repository": { + "repository_base": 1, + "repository_path": "repository_path_value", + }, + "custom_repository": {"uri": "uri_value"}, + }, + "yum_repository": { + "public_repository": { + "repository_base": 1, + "repository_path": "repository_path_value", + }, + "custom_repository": {"uri": "uri_value"}, + }, + "common_repository": {"uri": "uri_value"}, + "description": "description_value", + "upstream_credentials": { + "username_password_credentials": { + "username": "username_value", + "password_secret_version": "password_secret_version_value", + } + }, + "disable_upstream_validation": True, + }, + "name": "name_value", + "format_": 1, + "description": "description_value", + "labels": {}, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "kms_key_name": "kms_key_name_value", + "mode": 1, + "cleanup_policies": {}, + "size_bytes": 1089, + "satisfies_pzs": True, + "cleanup_policy_dry_run": True, + "vulnerability_scanning_config": { + "enablement_config": 1, + "last_enable_time": {}, + "enablement_state": 1, + "enablement_state_reason": "enablement_state_reason_value", + }, + "disallow_unspecified_mode": True, + "satisfies_pzi": True, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = gda_repository.CreateRepositoryRequest.meta.fields["repository"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["repository"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["repository"][field])): + del request_init["repository"][field][i][subfield] + else: + del request_init["repository"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = artifact.ListMavenArtifactsResponse( - next_page_token="next_page_token_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListMavenArtifactsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_maven_artifacts(request) + response = client.create_repository(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMavenArtifactsPager) - assert response.next_page_token == "next_page_token_value" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_maven_artifacts_rest_interceptors(null_interceptor): +def test_create_repository_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -22969,14 +32120,16 @@ def test_list_maven_artifacts_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_maven_artifacts" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_create_repository" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_maven_artifacts" + transports.ArtifactRegistryRestInterceptor, "pre_create_repository" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = artifact.ListMavenArtifactsRequest.pb( - artifact.ListMavenArtifactsRequest() + pb_message = gda_repository.CreateRepositoryRequest.pb( + gda_repository.CreateRepositoryRequest() ) transcode.return_value = { "method": "post", @@ -22987,20 +32140,18 @@ def test_list_maven_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = artifact.ListMavenArtifactsResponse.to_json( - artifact.ListMavenArtifactsResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = artifact.ListMavenArtifactsRequest() + request = gda_repository.CreateRepositoryRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = artifact.ListMavenArtifactsResponse() + post.return_value = operations_pb2.Operation() - client.list_maven_artifacts( + client.create_repository( request, metadata=[ ("key", "val"), @@ -23012,15 +32163,17 @@ def test_list_maven_artifacts_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_maven_artifact_rest_bad_request( - request_type=artifact.GetMavenArtifactRequest, +def test_update_repository_rest_bad_request( + request_type=gda_repository.UpdateRepositoryRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4" + "repository": { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } } request = request_type(**request_init) @@ -23035,36 +32188,180 @@ def test_get_maven_artifact_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_maven_artifact(request) + client.update_repository(request) @pytest.mark.parametrize( "request_type", [ - artifact.GetMavenArtifactRequest, + gda_repository.UpdateRepositoryRequest, dict, ], ) -def test_get_maven_artifact_rest_call_success(request_type): +def test_update_repository_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/mavenArtifacts/sample4" + "repository": { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } + } + request_init["repository"] = { + "maven_config": {"allow_snapshot_overwrites": True, "version_policy": 1}, + "docker_config": {"immutable_tags": True}, + "virtual_repository_config": { + "upstream_policies": [ + {"id": "id_value", "repository": "repository_value", "priority": 898} + ] + }, + "remote_repository_config": { + "docker_repository": { + "public_repository": 1, + "custom_repository": {"uri": "uri_value"}, + }, + "maven_repository": { + "public_repository": 1, + "custom_repository": {"uri": "uri_value"}, + }, + "npm_repository": { + "public_repository": 1, + "custom_repository": {"uri": "uri_value"}, + }, + "python_repository": { + "public_repository": 1, + "custom_repository": {"uri": "uri_value"}, + }, + "apt_repository": { + "public_repository": { + "repository_base": 1, + "repository_path": "repository_path_value", + }, + "custom_repository": {"uri": "uri_value"}, + }, + "yum_repository": { + "public_repository": { + "repository_base": 1, + "repository_path": "repository_path_value", + }, + "custom_repository": {"uri": "uri_value"}, + }, + "common_repository": {"uri": "uri_value"}, + "description": "description_value", + "upstream_credentials": { + "username_password_credentials": { + "username": "username_value", + "password_secret_version": "password_secret_version_value", + } + }, + "disable_upstream_validation": True, + }, + "name": "projects/sample1/locations/sample2/repositories/sample3", + "format_": 1, + "description": "description_value", + "labels": {}, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "kms_key_name": "kms_key_name_value", + "mode": 1, + "cleanup_policies": {}, + "size_bytes": 1089, + "satisfies_pzs": True, + "cleanup_policy_dry_run": True, + "vulnerability_scanning_config": { + "enablement_config": 1, + "last_enable_time": {}, + "enablement_state": 1, + "enablement_state_reason": "enablement_state_reason_value", + }, + "disallow_unspecified_mode": True, + "satisfies_pzi": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = gda_repository.UpdateRepositoryRequest.meta.fields["repository"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["repository"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["repository"][field])): + del request_init["repository"][field][i][subfield] + else: + del request_init["repository"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = artifact.MavenArtifact( + return_value = gda_repository.Repository( name="name_value", - pom_uri="pom_uri_value", - group_id="group_id_value", - artifact_id="artifact_id_value", - version="version_value", + format_=gda_repository.Repository.Format.DOCKER, + description="description_value", + kms_key_name="kms_key_name_value", + mode=gda_repository.Repository.Mode.STANDARD_REPOSITORY, + size_bytes=1089, + satisfies_pzs=True, + cleanup_policy_dry_run=True, + disallow_unspecified_mode=True, + satisfies_pzi=True, ) # Wrap the value into a proper Response obj @@ -23072,23 +32369,28 @@ def test_get_maven_artifact_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = artifact.MavenArtifact.pb(return_value) + return_value = gda_repository.Repository.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_maven_artifact(request) + response = client.update_repository(request) # Establish that the response is the type that we expect. - assert isinstance(response, artifact.MavenArtifact) + assert isinstance(response, gda_repository.Repository) 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" + assert response.format_ == gda_repository.Repository.Format.DOCKER + assert response.description == "description_value" + assert response.kms_key_name == "kms_key_name_value" + assert response.mode == gda_repository.Repository.Mode.STANDARD_REPOSITORY + assert response.size_bytes == 1089 + assert response.satisfies_pzs is True + assert response.cleanup_policy_dry_run is True + assert response.disallow_unspecified_mode is True + assert response.satisfies_pzi is True @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_maven_artifact_rest_interceptors(null_interceptor): +def test_update_repository_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -23102,14 +32404,14 @@ def test_get_maven_artifact_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_maven_artifact" + transports.ArtifactRegistryRestInterceptor, "post_update_repository" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_maven_artifact" + transports.ArtifactRegistryRestInterceptor, "pre_update_repository" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = artifact.GetMavenArtifactRequest.pb( - artifact.GetMavenArtifactRequest() + pb_message = gda_repository.UpdateRepositoryRequest.pb( + gda_repository.UpdateRepositoryRequest() ) transcode.return_value = { "method": "post", @@ -23120,18 +32422,18 @@ def test_get_maven_artifact_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = artifact.MavenArtifact.to_json(artifact.MavenArtifact()) + return_value = gda_repository.Repository.to_json(gda_repository.Repository()) req.return_value.content = return_value - request = artifact.GetMavenArtifactRequest() + request = gda_repository.UpdateRepositoryRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = artifact.MavenArtifact() + post.return_value = gda_repository.Repository() - client.get_maven_artifact( + client.update_repository( request, metadata=[ ("key", "val"), @@ -23143,14 +32445,14 @@ def test_get_maven_artifact_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_npm_packages_rest_bad_request( - request_type=artifact.ListNpmPackagesRequest, +def test_delete_repository_rest_bad_request( + request_type=repository.DeleteRepositoryRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23164,50 +32466,44 @@ def test_list_npm_packages_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_npm_packages(request) + client.delete_repository(request) @pytest.mark.parametrize( "request_type", [ - artifact.ListNpmPackagesRequest, + repository.DeleteRepositoryRequest, dict, ], ) -def test_list_npm_packages_rest_call_success(request_type): +def test_delete_repository_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = artifact.ListNpmPackagesResponse( - next_page_token="next_page_token_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.ListNpmPackagesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_npm_packages(request) + response = client.delete_repository(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListNpmPackagesPager) - assert response.next_page_token == "next_page_token_value" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_npm_packages_rest_interceptors(null_interceptor): +def test_delete_repository_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -23221,14 +32517,16 @@ def test_list_npm_packages_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_npm_packages" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_delete_repository" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_npm_packages" + transports.ArtifactRegistryRestInterceptor, "pre_delete_repository" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = artifact.ListNpmPackagesRequest.pb( - artifact.ListNpmPackagesRequest() + pb_message = repository.DeleteRepositoryRequest.pb( + repository.DeleteRepositoryRequest() ) transcode.return_value = { "method": "post", @@ -23239,20 +32537,18 @@ def test_list_npm_packages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = artifact.ListNpmPackagesResponse.to_json( - artifact.ListNpmPackagesResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = artifact.ListNpmPackagesRequest() + request = repository.DeleteRepositoryRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = artifact.ListNpmPackagesResponse() + post.return_value = operations_pb2.Operation() - client.list_npm_packages( + client.delete_repository( request, metadata=[ ("key", "val"), @@ -23264,14 +32560,12 @@ def test_list_npm_packages_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_npm_package_rest_bad_request(request_type=artifact.GetNpmPackageRequest): +def test_list_packages_rest_bad_request(request_type=package.ListPackagesRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23285,35 +32579,30 @@ def test_get_npm_package_rest_bad_request(request_type=artifact.GetNpmPackageReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_npm_package(request) + client.list_packages(request) @pytest.mark.parametrize( "request_type", [ - artifact.GetNpmPackageRequest, + package.ListPackagesRequest, dict, ], ) -def test_get_npm_package_rest_call_success(request_type): +def test_list_packages_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/npmPackages/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = artifact.NpmPackage( - name="name_value", - package_name="package_name_value", - version="version_value", - tags=["tags_value"], + return_value = package.ListPackagesResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -23321,22 +32610,19 @@ def test_get_npm_package_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = artifact.NpmPackage.pb(return_value) + return_value = package.ListPackagesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_npm_package(request) + response = client.list_packages(request) # Establish that the response is the type that we expect. - 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"] + assert isinstance(response, pagers.ListPackagesPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_npm_package_rest_interceptors(null_interceptor): +def test_list_packages_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -23350,13 +32636,13 @@ def test_get_npm_package_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_npm_package" + transports.ArtifactRegistryRestInterceptor, "post_list_packages" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_npm_package" + transports.ArtifactRegistryRestInterceptor, "pre_list_packages" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = artifact.GetNpmPackageRequest.pb(artifact.GetNpmPackageRequest()) + pb_message = package.ListPackagesRequest.pb(package.ListPackagesRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -23366,18 +32652,20 @@ def test_get_npm_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = artifact.NpmPackage.to_json(artifact.NpmPackage()) + return_value = package.ListPackagesResponse.to_json( + package.ListPackagesResponse() + ) req.return_value.content = return_value - request = artifact.GetNpmPackageRequest() + request = package.ListPackagesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = artifact.NpmPackage() + post.return_value = package.ListPackagesResponse() - client.get_npm_package( + client.list_packages( request, metadata=[ ("key", "val"), @@ -23389,14 +32677,14 @@ def test_get_npm_package_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_python_packages_rest_bad_request( - request_type=artifact.ListPythonPackagesRequest, -): +def test_get_package_rest_bad_request(request_type=package.GetPackageRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23410,30 +32698,33 @@ def test_list_python_packages_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_python_packages(request) + client.get_package(request) @pytest.mark.parametrize( "request_type", [ - artifact.ListPythonPackagesRequest, + package.GetPackageRequest, dict, ], ) -def test_list_python_packages_rest_call_success(request_type): +def test_get_package_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = artifact.ListPythonPackagesResponse( - next_page_token="next_page_token_value", + return_value = package.Package( + name="name_value", + display_name="display_name_value", ) # Wrap the value into a proper Response obj @@ -23441,19 +32732,20 @@ def test_list_python_packages_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = artifact.ListPythonPackagesResponse.pb(return_value) + return_value = package.Package.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_python_packages(request) + response = client.get_package(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPythonPackagesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, package.Package) + assert response.name == "name_value" + assert response.display_name == "display_name_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_python_packages_rest_interceptors(null_interceptor): +def test_get_package_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -23467,15 +32759,13 @@ def test_list_python_packages_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_python_packages" + transports.ArtifactRegistryRestInterceptor, "post_get_package" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_python_packages" + transports.ArtifactRegistryRestInterceptor, "pre_get_package" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = artifact.ListPythonPackagesRequest.pb( - artifact.ListPythonPackagesRequest() - ) + pb_message = package.GetPackageRequest.pb(package.GetPackageRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -23485,20 +32775,18 @@ def test_list_python_packages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = artifact.ListPythonPackagesResponse.to_json( - artifact.ListPythonPackagesResponse() - ) + return_value = package.Package.to_json(package.Package()) req.return_value.content = return_value - request = artifact.ListPythonPackagesRequest() + request = package.GetPackageRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = artifact.ListPythonPackagesResponse() + post.return_value = package.Package() - client.list_python_packages( + client.get_package( request, metadata=[ ("key", "val"), @@ -23510,15 +32798,13 @@ def test_list_python_packages_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_python_package_rest_bad_request( - request_type=artifact.GetPythonPackageRequest, -): +def test_delete_package_rest_bad_request(request_type=package.DeletePackageRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" } request = request_type(**request_init) @@ -23533,58 +32819,46 @@ def test_get_python_package_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_python_package(request) + client.delete_package(request) @pytest.mark.parametrize( "request_type", [ - artifact.GetPythonPackageRequest, + package.DeletePackageRequest, dict, ], ) -def test_get_python_package_rest_call_success(request_type): +def test_delete_package_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/pythonPackages/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = artifact.PythonPackage( - name="name_value", - uri="uri_value", - package_name="package_name_value", - version="version_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = artifact.PythonPackage.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_python_package(request) + response = client.delete_package(request) # 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" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_python_package_rest_interceptors(null_interceptor): +def test_delete_package_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -23598,15 +32872,15 @@ def test_get_python_package_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_python_package" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_delete_package" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_python_package" + transports.ArtifactRegistryRestInterceptor, "pre_delete_package" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = artifact.GetPythonPackageRequest.pb( - artifact.GetPythonPackageRequest() - ) + pb_message = package.DeletePackageRequest.pb(package.DeletePackageRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -23616,18 +32890,18 @@ def test_get_python_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = artifact.PythonPackage.to_json(artifact.PythonPackage()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = artifact.GetPythonPackageRequest() + request = package.DeletePackageRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = artifact.PythonPackage() + post.return_value = operations_pb2.Operation() - client.get_python_package( + client.delete_package( request, metadata=[ ("key", "val"), @@ -23639,14 +32913,14 @@ def test_get_python_package_rest_interceptors(null_interceptor): post.assert_called_once() -def test_import_apt_artifacts_rest_bad_request( - request_type=apt_artifact.ImportAptArtifactsRequest, -): +def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23660,44 +32934,52 @@ def test_import_apt_artifacts_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.import_apt_artifacts(request) + client.list_versions(request) @pytest.mark.parametrize( "request_type", [ - apt_artifact.ImportAptArtifactsRequest, + version.ListVersionsRequest, dict, ], ) -def test_import_apt_artifacts_rest_call_success(request_type): +def test_list_versions_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = version.ListVersionsResponse( + next_page_token="next_page_token_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = version.ListVersionsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.import_apt_artifacts(request) + response = client.list_versions(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, pagers.ListVersionsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_import_apt_artifacts_rest_interceptors(null_interceptor): +def test_list_versions_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -23711,17 +32993,13 @@ def test_import_apt_artifacts_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_import_apt_artifacts" + transports.ArtifactRegistryRestInterceptor, "post_list_versions" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_import_apt_artifacts" + transports.ArtifactRegistryRestInterceptor, "pre_list_versions" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = apt_artifact.ImportAptArtifactsRequest.pb( - apt_artifact.ImportAptArtifactsRequest() - ) + pb_message = version.ListVersionsRequest.pb(version.ListVersionsRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -23731,18 +33009,20 @@ def test_import_apt_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = version.ListVersionsResponse.to_json( + version.ListVersionsResponse() + ) req.return_value.content = return_value - request = apt_artifact.ImportAptArtifactsRequest() + request = version.ListVersionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = version.ListVersionsResponse() - client.import_apt_artifacts( + client.list_versions( request, metadata=[ ("key", "val"), @@ -23754,14 +33034,14 @@ def test_import_apt_artifacts_rest_interceptors(null_interceptor): post.assert_called_once() -def test_import_yum_artifacts_rest_bad_request( - request_type=yum_artifact.ImportYumArtifactsRequest, -): +def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23775,44 +33055,54 @@ def test_import_yum_artifacts_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.import_yum_artifacts(request) + client.get_version(request) @pytest.mark.parametrize( "request_type", [ - yum_artifact.ImportYumArtifactsRequest, + version.GetVersionRequest, dict, ], ) -def test_import_yum_artifacts_rest_call_success(request_type): +def test_get_version_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = version.Version( + name="name_value", + description="description_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = version.Version.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.import_yum_artifacts(request) + response = client.get_version(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, version.Version) + assert response.name == "name_value" + assert response.description == "description_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_import_yum_artifacts_rest_interceptors(null_interceptor): +def test_get_version_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -23825,18 +33115,14 @@ def test_import_yum_artifacts_rest_interceptors(null_interceptor): type(client.transport._session), "request" ) as req, mock.patch.object( path_template, "transcode" - ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_import_yum_artifacts" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_get_version" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_import_yum_artifacts" + transports.ArtifactRegistryRestInterceptor, "pre_get_version" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = yum_artifact.ImportYumArtifactsRequest.pb( - yum_artifact.ImportYumArtifactsRequest() - ) + pb_message = version.GetVersionRequest.pb(version.GetVersionRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -23846,18 +33132,18 @@ def test_import_yum_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = version.Version.to_json(version.Version()) req.return_value.content = return_value - request = yum_artifact.ImportYumArtifactsRequest() + request = version.GetVersionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = version.Version() - client.import_yum_artifacts( + client.get_version( request, metadata=[ ("key", "val"), @@ -23869,14 +33155,14 @@ def test_import_yum_artifacts_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_repositories_rest_bad_request( - request_type=repository.ListRepositoriesRequest, -): +def test_delete_version_rest_bad_request(request_type=version.DeleteVersionRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23890,50 +33176,46 @@ def test_list_repositories_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_repositories(request) + client.delete_version(request) @pytest.mark.parametrize( "request_type", [ - repository.ListRepositoriesRequest, + version.DeleteVersionRequest, dict, ], ) -def test_list_repositories_rest_call_success(request_type): +def test_delete_version_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = repository.ListRepositoriesResponse( - next_page_token="next_page_token_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.ListRepositoriesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_repositories(request) + response = client.delete_version(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRepositoriesPager) - assert response.next_page_token == "next_page_token_value" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_repositories_rest_interceptors(null_interceptor): +def test_delete_version_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -23947,15 +33229,15 @@ def test_list_repositories_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_repositories" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_delete_version" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_repositories" + transports.ArtifactRegistryRestInterceptor, "pre_delete_version" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = repository.ListRepositoriesRequest.pb( - repository.ListRepositoriesRequest() - ) + pb_message = version.DeleteVersionRequest.pb(version.DeleteVersionRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -23965,20 +33247,18 @@ def test_list_repositories_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = repository.ListRepositoriesResponse.to_json( - repository.ListRepositoriesResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = repository.ListRepositoriesRequest() + request = version.DeleteVersionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = repository.ListRepositoriesResponse() + post.return_value = operations_pb2.Operation() - client.list_repositories( + client.delete_version( request, metadata=[ ("key", "val"), @@ -23990,12 +33270,16 @@ def test_list_repositories_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_repository_rest_bad_request(request_type=repository.GetRepositoryRequest): +def test_batch_delete_versions_rest_bad_request( + request_type=version.BatchDeleteVersionsRequest, +): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -24009,64 +33293,46 @@ def test_get_repository_rest_bad_request(request_type=repository.GetRepositoryRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_repository(request) + client.batch_delete_versions(request) @pytest.mark.parametrize( "request_type", [ - repository.GetRepositoryRequest, + version.BatchDeleteVersionsRequest, dict, ], ) -def test_get_repository_rest_call_success(request_type): +def test_batch_delete_versions_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = repository.Repository( - name="name_value", - format_=repository.Repository.Format.DOCKER, - description="description_value", - kms_key_name="kms_key_name_value", - mode=repository.Repository.Mode.STANDARD_REPOSITORY, - size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = repository.Repository.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_repository(request) + response = client.batch_delete_versions(request) # 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 response.mode == repository.Repository.Mode.STANDARD_REPOSITORY - assert response.size_bytes == 1089 - assert response.satisfies_pzs is True - assert response.cleanup_policy_dry_run is True + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_repository_rest_interceptors(null_interceptor): +def test_batch_delete_versions_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -24080,14 +33346,16 @@ def test_get_repository_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_repository" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_batch_delete_versions" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_repository" + transports.ArtifactRegistryRestInterceptor, "pre_batch_delete_versions" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = repository.GetRepositoryRequest.pb( - repository.GetRepositoryRequest() + pb_message = version.BatchDeleteVersionsRequest.pb( + version.BatchDeleteVersionsRequest() ) transcode.return_value = { "method": "post", @@ -24098,18 +33366,18 @@ def test_get_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = repository.Repository.to_json(repository.Repository()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = repository.GetRepositoryRequest() + request = version.BatchDeleteVersionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = repository.Repository() + post.return_value = operations_pb2.Operation() - client.get_repository( + client.batch_delete_versions( request, metadata=[ ("key", "val"), @@ -24121,14 +33389,16 @@ def test_get_repository_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_repository_rest_bad_request( - request_type=gda_repository.CreateRepositoryRequest, -): +def test_update_version_rest_bad_request(request_type=gda_version.UpdateVersionRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "version": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -24142,75 +33412,42 @@ def test_create_repository_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.create_repository(request) + client.update_version(request) @pytest.mark.parametrize( "request_type", [ - gda_repository.CreateRepositoryRequest, + gda_version.UpdateVersionRequest, dict, ], ) -def test_create_repository_rest_call_success(request_type): +def test_update_version_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["repository"] = { - "maven_config": {"allow_snapshot_overwrites": True, "version_policy": 1}, - "docker_config": {"immutable_tags": True}, - "virtual_repository_config": { - "upstream_policies": [ - {"id": "id_value", "repository": "repository_value", "priority": 898} - ] - }, - "remote_repository_config": { - "docker_repository": {"public_repository": 1}, - "maven_repository": {"public_repository": 1}, - "npm_repository": {"public_repository": 1}, - "python_repository": {"public_repository": 1}, - "apt_repository": { - "public_repository": { - "repository_base": 1, - "repository_path": "repository_path_value", - } - }, - "yum_repository": { - "public_repository": { - "repository_base": 1, - "repository_path": "repository_path_value", - } - }, - "description": "description_value", - "upstream_credentials": { - "username_password_credentials": { - "username": "username_value", - "password_secret_version": "password_secret_version_value", - } - }, - }, - "name": "name_value", - "format_": 1, + request_init = { + "version": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + } + } + request_init["version"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5", "description": "description_value", - "labels": {}, "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, - "kms_key_name": "kms_key_name_value", - "mode": 1, - "cleanup_policies": {}, - "size_bytes": 1089, - "satisfies_pzs": True, - "cleanup_policy_dry_run": True, + "related_tags": [{"name": "name_value", "version": "version_value"}], + "metadata": {"fields": {}}, + "annotations": {}, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = gda_repository.CreateRepositoryRequest.meta.fields["repository"] + test_field = gda_version.UpdateVersionRequest.meta.fields["version"] def get_message_fields(field): # Given a field which is a message (composite type), return a list with @@ -24238,7 +33475,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["repository"].items(): # pragma: NO COVER + for field, value in request_init["version"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -24268,31 +33505,39 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["repository"][field])): - del request_init["repository"][field][i][subfield] + for i in range(0, len(request_init["version"][field])): + del request_init["version"][field][i][subfield] else: - del request_init["repository"][field][subfield] + del request_init["version"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = gda_version.Version( + name="name_value", + description="description_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = gda_version.Version.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_repository(request) + response = client.update_version(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, gda_version.Version) + assert response.name == "name_value" + assert response.description == "description_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_repository_rest_interceptors(null_interceptor): +def test_update_version_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -24306,16 +33551,14 @@ def test_create_repository_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_create_repository" + transports.ArtifactRegistryRestInterceptor, "post_update_version" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_create_repository" + transports.ArtifactRegistryRestInterceptor, "pre_update_version" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = gda_repository.CreateRepositoryRequest.pb( - gda_repository.CreateRepositoryRequest() + pb_message = gda_version.UpdateVersionRequest.pb( + gda_version.UpdateVersionRequest() ) transcode.return_value = { "method": "post", @@ -24326,18 +33569,18 @@ def test_create_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = gda_version.Version.to_json(gda_version.Version()) req.return_value.content = return_value - request = gda_repository.CreateRepositoryRequest() + request = gda_version.UpdateVersionRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = gda_version.Version() - client.create_repository( + client.update_version( request, metadata=[ ("key", "val"), @@ -24349,18 +33592,12 @@ def test_create_repository_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_repository_rest_bad_request( - request_type=gda_repository.UpdateRepositoryRequest, -): +def test_list_files_rest_bad_request(request_type=file.ListFilesRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "repository": { - "name": "projects/sample1/locations/sample2/repositories/sample3" - } - } + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -24374,154 +33611,151 @@ def test_update_repository_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_repository(request) + client.list_files(request) @pytest.mark.parametrize( "request_type", [ - gda_repository.UpdateRepositoryRequest, + file.ListFilesRequest, dict, ], ) -def test_update_repository_rest_call_success(request_type): +def test_list_files_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "repository": { - "name": "projects/sample1/locations/sample2/repositories/sample3" + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = file.ListFilesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = file.ListFilesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_files(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFilesPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_files_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_list_files" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_list_files" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = file.ListFilesRequest.pb(file.ListFilesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, } - } - request_init["repository"] = { - "maven_config": {"allow_snapshot_overwrites": True, "version_policy": 1}, - "docker_config": {"immutable_tags": True}, - "virtual_repository_config": { - "upstream_policies": [ - {"id": "id_value", "repository": "repository_value", "priority": 898} - ] - }, - "remote_repository_config": { - "docker_repository": {"public_repository": 1}, - "maven_repository": {"public_repository": 1}, - "npm_repository": {"public_repository": 1}, - "python_repository": {"public_repository": 1}, - "apt_repository": { - "public_repository": { - "repository_base": 1, - "repository_path": "repository_path_value", - } - }, - "yum_repository": { - "public_repository": { - "repository_base": 1, - "repository_path": "repository_path_value", - } - }, - "description": "description_value", - "upstream_credentials": { - "username_password_credentials": { - "username": "username_value", - "password_secret_version": "password_secret_version_value", - } - }, - }, - "name": "projects/sample1/locations/sample2/repositories/sample3", - "format_": 1, - "description": "description_value", - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "kms_key_name": "kms_key_name_value", - "mode": 1, - "cleanup_policies": {}, - "size_bytes": 1089, - "satisfies_pzs": True, - "cleanup_policy_dry_run": True, - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - # Determine if the message type is proto-plus or protobuf - test_field = gda_repository.UpdateRepositoryRequest.meta.fields["repository"] + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = file.ListFilesResponse.to_json(file.ListFilesResponse()) + req.return_value.content = return_value - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] + request = file.ListFilesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = file.ListFilesResponse() - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + client.list_files( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields + pre.assert_called_once() + post.assert_called_once() - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - subfields_not_in_runtime = [] +def test_get_file_rest_bad_request(request_type=file.GetFileRequest): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } + request = request_type(**request_init) - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["repository"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.get_file(request) - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["repository"][field])): - del request_init["repository"][field][i][subfield] - else: - del request_init["repository"][field][subfield] +@pytest.mark.parametrize( + "request_type", + [ + file.GetFileRequest, + dict, + ], +) +def test_get_file_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gda_repository.Repository( + return_value = file.File( name="name_value", - format_=gda_repository.Repository.Format.DOCKER, - description="description_value", - kms_key_name="kms_key_name_value", - mode=gda_repository.Repository.Mode.STANDARD_REPOSITORY, size_bytes=1089, - satisfies_pzs=True, - cleanup_policy_dry_run=True, + owner="owner_value", ) # Wrap the value into a proper Response obj @@ -24529,26 +33763,21 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = gda_repository.Repository.pb(return_value) + return_value = file.File.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_repository(request) + response = client.get_file(request) # Establish that the response is the type that we expect. - assert isinstance(response, gda_repository.Repository) + assert isinstance(response, file.File) 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 response.mode == gda_repository.Repository.Mode.STANDARD_REPOSITORY assert response.size_bytes == 1089 - assert response.satisfies_pzs is True - assert response.cleanup_policy_dry_run is True + assert response.owner == "owner_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_repository_rest_interceptors(null_interceptor): +def test_get_file_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -24562,15 +33791,13 @@ def test_update_repository_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_update_repository" + transports.ArtifactRegistryRestInterceptor, "post_get_file" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_update_repository" + transports.ArtifactRegistryRestInterceptor, "pre_get_file" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = gda_repository.UpdateRepositoryRequest.pb( - gda_repository.UpdateRepositoryRequest() - ) + pb_message = file.GetFileRequest.pb(file.GetFileRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -24580,18 +33807,18 @@ def test_update_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = gda_repository.Repository.to_json(gda_repository.Repository()) + return_value = file.File.to_json(file.File()) req.return_value.content = return_value - request = gda_repository.UpdateRepositoryRequest() + request = file.GetFileRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gda_repository.Repository() + post.return_value = file.File() - client.update_repository( + client.get_file( request, metadata=[ ("key", "val"), @@ -24603,14 +33830,14 @@ def test_update_repository_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_repository_rest_bad_request( - request_type=repository.DeleteRepositoryRequest, -): +def test_delete_file_rest_bad_request(request_type=file.DeleteFileRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -24624,23 +33851,25 @@ def test_delete_repository_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_repository(request) + client.delete_file(request) @pytest.mark.parametrize( "request_type", [ - repository.DeleteRepositoryRequest, + file.DeleteFileRequest, dict, ], ) -def test_delete_repository_rest_call_success(request_type): +def test_delete_file_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -24654,14 +33883,14 @@ def test_delete_repository_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_repository(request) + response = client.delete_file(request) # Establish that the response is the type that we expect. json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_repository_rest_interceptors(null_interceptor): +def test_delete_file_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -24677,15 +33906,13 @@ def test_delete_repository_rest_interceptors(null_interceptor): ) as transcode, mock.patch.object( operation.Operation, "_set_result_from_operation" ), mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_delete_repository" + transports.ArtifactRegistryRestInterceptor, "post_delete_file" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_delete_repository" + transports.ArtifactRegistryRestInterceptor, "pre_delete_file" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = repository.DeleteRepositoryRequest.pb( - repository.DeleteRepositoryRequest() - ) + pb_message = file.DeleteFileRequest.pb(file.DeleteFileRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -24698,7 +33925,7 @@ def test_delete_repository_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = repository.DeleteRepositoryRequest() + request = file.DeleteFileRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -24706,7 +33933,7 @@ def test_delete_repository_rest_interceptors(null_interceptor): pre.return_value = request, metadata post.return_value = operations_pb2.Operation() - client.delete_repository( + client.delete_file( request, metadata=[ ("key", "val"), @@ -24718,12 +33945,16 @@ def test_delete_repository_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_packages_rest_bad_request(request_type=package.ListPackagesRequest): +def test_update_file_rest_bad_request(request_type=gda_file.UpdateFileRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "file": { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -24737,30 +33968,113 @@ def test_list_packages_rest_bad_request(request_type=package.ListPackagesRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_packages(request) + client.update_file(request) @pytest.mark.parametrize( "request_type", [ - package.ListPackagesRequest, + gda_file.UpdateFileRequest, dict, ], ) -def test_list_packages_rest_call_success(request_type): +def test_update_file_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "file": { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + } + } + request_init["file"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4", + "size_bytes": 1089, + "hashes": [{"type_": 1, "value": b"value_blob"}], + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "owner": "owner_value", + "fetch_time": {}, + "annotations": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = gda_file.UpdateFileRequest.meta.fields["file"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["file"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["file"][field])): + del request_init["file"][field][i][subfield] + else: + del request_init["file"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = package.ListPackagesResponse( - next_page_token="next_page_token_value", + return_value = gda_file.File( + name="name_value", + size_bytes=1089, + owner="owner_value", ) # Wrap the value into a proper Response obj @@ -24768,19 +34082,21 @@ def test_list_packages_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = package.ListPackagesResponse.pb(return_value) + return_value = gda_file.File.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_packages(request) + response = client.update_file(request) # 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, gda_file.File) + assert response.name == "name_value" + assert response.size_bytes == 1089 + assert response.owner == "owner_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_packages_rest_interceptors(null_interceptor): +def test_update_file_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -24794,13 +34110,13 @@ def test_list_packages_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_packages" + transports.ArtifactRegistryRestInterceptor, "post_update_file" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_packages" + transports.ArtifactRegistryRestInterceptor, "pre_update_file" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = package.ListPackagesRequest.pb(package.ListPackagesRequest()) + pb_message = gda_file.UpdateFileRequest.pb(gda_file.UpdateFileRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -24810,20 +34126,18 @@ def test_list_packages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = package.ListPackagesResponse.to_json( - package.ListPackagesResponse() - ) + return_value = gda_file.File.to_json(gda_file.File()) req.return_value.content = return_value - request = package.ListPackagesRequest() + request = gda_file.UpdateFileRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = package.ListPackagesResponse() + post.return_value = gda_file.File() - client.list_packages( + client.update_file( request, metadata=[ ("key", "val"), @@ -24835,13 +34149,13 @@ def test_list_packages_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_package_rest_bad_request(request_type=package.GetPackageRequest): +def test_list_tags_rest_bad_request(request_type=tag.ListTagsRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" } request = request_type(**request_init) @@ -24856,33 +34170,32 @@ def test_get_package_rest_bad_request(request_type=package.GetPackageRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_package(request) + client.list_tags(request) @pytest.mark.parametrize( "request_type", [ - package.GetPackageRequest, + tag.ListTagsRequest, dict, ], ) -def test_get_package_rest_call_success(request_type): +def test_list_tags_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = package.Package( - name="name_value", - display_name="display_name_value", + return_value = tag.ListTagsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -24890,20 +34203,19 @@ def test_get_package_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = package.Package.pb(return_value) + return_value = tag.ListTagsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_package(request) + response = client.list_tags(request) # 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.ListTagsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_package_rest_interceptors(null_interceptor): +def test_list_tags_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -24917,13 +34229,13 @@ def test_get_package_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_package" + transports.ArtifactRegistryRestInterceptor, "post_list_tags" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_package" + transports.ArtifactRegistryRestInterceptor, "pre_list_tags" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = package.GetPackageRequest.pb(package.GetPackageRequest()) + pb_message = tag.ListTagsRequest.pb(tag.ListTagsRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -24933,18 +34245,18 @@ def test_get_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = package.Package.to_json(package.Package()) + return_value = tag.ListTagsResponse.to_json(tag.ListTagsResponse()) req.return_value.content = return_value - request = package.GetPackageRequest() + request = tag.ListTagsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = package.Package() + post.return_value = tag.ListTagsResponse() - client.get_package( + client.list_tags( request, metadata=[ ("key", "val"), @@ -24956,13 +34268,13 @@ def test_get_package_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_package_rest_bad_request(request_type=package.DeletePackageRequest): +def test_get_tag_rest_bad_request(request_type=tag.GetTagRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" } request = request_type(**request_init) @@ -24977,46 +34289,54 @@ def test_delete_package_rest_bad_request(request_type=package.DeletePackageReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_package(request) + client.get_tag(request) @pytest.mark.parametrize( "request_type", [ - package.DeletePackageRequest, + tag.GetTagRequest, dict, ], ) -def test_delete_package_rest_call_success(request_type): +def test_get_tag_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = tag.Tag( + name="name_value", + version="version_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = tag.Tag.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_package(request) + response = client.get_tag(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, tag.Tag) + assert response.name == "name_value" + assert response.version == "version_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_package_rest_interceptors(null_interceptor): +def test_get_tag_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25030,15 +34350,13 @@ def test_delete_package_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_delete_package" + transports.ArtifactRegistryRestInterceptor, "post_get_tag" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_delete_package" + transports.ArtifactRegistryRestInterceptor, "pre_get_tag" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = package.DeletePackageRequest.pb(package.DeletePackageRequest()) + pb_message = tag.GetTagRequest.pb(tag.GetTagRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -25048,18 +34366,18 @@ def test_delete_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = tag.Tag.to_json(tag.Tag()) req.return_value.content = return_value - request = package.DeletePackageRequest() + request = tag.GetTagRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = tag.Tag() - client.delete_package( + client.get_tag( request, metadata=[ ("key", "val"), @@ -25071,7 +34389,7 @@ def test_delete_package_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest): +def test_create_tag_rest_bad_request(request_type=gda_tag.CreateTagRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -25092,17 +34410,17 @@ def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_versions(request) + client.create_tag(request) @pytest.mark.parametrize( "request_type", [ - version.ListVersionsRequest, + gda_tag.CreateTagRequest, dict, ], ) -def test_list_versions_rest_call_success(request_type): +def test_create_tag_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -25111,13 +34429,82 @@ def test_list_versions_rest_call_success(request_type): request_init = { "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" } + request_init["tag"] = {"name": "name_value", "version": "version_value"} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = gda_tag.CreateTagRequest.meta.fields["tag"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["tag"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["tag"][field])): + del request_init["tag"][field][i][subfield] + else: + del request_init["tag"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = version.ListVersionsResponse( - next_page_token="next_page_token_value", + return_value = gda_tag.Tag( + name="name_value", + version="version_value", ) # Wrap the value into a proper Response obj @@ -25125,19 +34512,20 @@ def test_list_versions_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = version.ListVersionsResponse.pb(return_value) + return_value = gda_tag.Tag.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_versions(request) + response = client.create_tag(request) # 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, gda_tag.Tag) + assert response.name == "name_value" + assert response.version == "version_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_versions_rest_interceptors(null_interceptor): +def test_create_tag_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25151,13 +34539,13 @@ def test_list_versions_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_versions" + transports.ArtifactRegistryRestInterceptor, "post_create_tag" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_versions" + transports.ArtifactRegistryRestInterceptor, "pre_create_tag" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = version.ListVersionsRequest.pb(version.ListVersionsRequest()) + pb_message = gda_tag.CreateTagRequest.pb(gda_tag.CreateTagRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -25167,20 +34555,18 @@ def test_list_versions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = version.ListVersionsResponse.to_json( - version.ListVersionsResponse() - ) + return_value = gda_tag.Tag.to_json(gda_tag.Tag()) req.return_value.content = return_value - request = version.ListVersionsRequest() + request = gda_tag.CreateTagRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = version.ListVersionsResponse() + post.return_value = gda_tag.Tag() - client.list_versions( + client.create_tag( request, metadata=[ ("key", "val"), @@ -25192,13 +34578,15 @@ def test_list_versions_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): +def test_update_tag_rest_bad_request(request_type=gda_tag.UpdateTagRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + "tag": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + } } request = request_type(**request_init) @@ -25213,33 +34601,106 @@ def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_version(request) + client.update_tag(request) @pytest.mark.parametrize( "request_type", [ - version.GetVersionRequest, + gda_tag.UpdateTagRequest, dict, ], ) -def test_get_version_rest_call_success(request_type): +def test_update_tag_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + "tag": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + } + } + request_init["tag"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5", + "version": "version_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = gda_tag.UpdateTagRequest.meta.fields["tag"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["tag"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["tag"][field])): + del request_init["tag"][field][i][subfield] + else: + del request_init["tag"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = version.Version( + return_value = gda_tag.Tag( name="name_value", - description="description_value", + version="version_value", ) # Wrap the value into a proper Response obj @@ -25247,20 +34708,20 @@ def test_get_version_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = version.Version.pb(return_value) + return_value = gda_tag.Tag.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_version(request) + response = client.update_tag(request) # Establish that the response is the type that we expect. - assert isinstance(response, version.Version) + assert isinstance(response, gda_tag.Tag) assert response.name == "name_value" - assert response.description == "description_value" + assert response.version == "version_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_version_rest_interceptors(null_interceptor): +def test_update_tag_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25274,13 +34735,13 @@ def test_get_version_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_version" + transports.ArtifactRegistryRestInterceptor, "post_update_tag" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_version" + transports.ArtifactRegistryRestInterceptor, "pre_update_tag" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = version.GetVersionRequest.pb(version.GetVersionRequest()) + pb_message = gda_tag.UpdateTagRequest.pb(gda_tag.UpdateTagRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -25290,18 +34751,18 @@ def test_get_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = version.Version.to_json(version.Version()) + return_value = gda_tag.Tag.to_json(gda_tag.Tag()) req.return_value.content = return_value - request = version.GetVersionRequest() + request = gda_tag.UpdateTagRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = version.Version() + post.return_value = gda_tag.Tag() - client.get_version( + client.update_tag( request, metadata=[ ("key", "val"), @@ -25313,13 +34774,13 @@ def test_get_version_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_version_rest_bad_request(request_type=version.DeleteVersionRequest): +def test_delete_tag_rest_bad_request(request_type=tag.DeleteTagRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" } request = request_type(**request_init) @@ -25334,46 +34795,46 @@ def test_delete_version_rest_bad_request(request_type=version.DeleteVersionReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_version(request) + client.delete_tag(request) @pytest.mark.parametrize( "request_type", [ - version.DeleteVersionRequest, + tag.DeleteTagRequest, dict, ], ) -def test_delete_version_rest_call_success(request_type): +def test_delete_tag_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/versions/sample5" + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = None # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_version(request) + response = client.delete_tag(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert response is None @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_version_rest_interceptors(null_interceptor): +def test_delete_tag_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25387,15 +34848,10 @@ def test_delete_version_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_delete_version" - ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_delete_version" + transports.ArtifactRegistryRestInterceptor, "pre_delete_tag" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = version.DeleteVersionRequest.pb(version.DeleteVersionRequest()) + pb_message = tag.DeleteTagRequest.pb(tag.DeleteTagRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -25405,18 +34861,15 @@ def test_delete_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - request = version.DeleteVersionRequest() + request = tag.DeleteTagRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - client.delete_version( + client.delete_tag( request, metadata=[ ("key", "val"), @@ -25425,19 +34878,14 @@ def test_delete_version_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_batch_delete_versions_rest_bad_request( - request_type=version.BatchDeleteVersionsRequest, -): +def test_create_rule_rest_bad_request(request_type=gda_rule.CreateRuleRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" - } + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -25451,46 +34899,135 @@ def test_batch_delete_versions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.batch_delete_versions(request) + client.create_rule(request) @pytest.mark.parametrize( "request_type", [ - version.BatchDeleteVersionsRequest, + gda_rule.CreateRuleRequest, dict, ], ) -def test_batch_delete_versions_rest_call_success(request_type): +def test_create_rule_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # send a request that will satisfy transcoding - request_init = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" - } + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init["rule"] = { + "name": "name_value", + "action": 1, + "operation": 1, + "condition": { + "expression": "expression_value", + "title": "title_value", + "description": "description_value", + "location": "location_value", + }, + "package_id": "package_id_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = gda_rule.CreateRuleRequest.meta.fields["rule"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["rule"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["rule"][field])): + del request_init["rule"][field][i][subfield] + else: + del request_init["rule"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + return_value = gda_rule.Rule( + name="name_value", + action=gda_rule.Rule.Action.ALLOW, + operation=gda_rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = gda_rule.Rule.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.batch_delete_versions(request) + response = client.create_rule(request) # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert isinstance(response, gda_rule.Rule) + assert response.name == "name_value" + assert response.action == gda_rule.Rule.Action.ALLOW + assert response.operation == gda_rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_batch_delete_versions_rest_interceptors(null_interceptor): +def test_create_rule_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25504,17 +35041,13 @@ def test_batch_delete_versions_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_batch_delete_versions" + transports.ArtifactRegistryRestInterceptor, "post_create_rule" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_batch_delete_versions" + transports.ArtifactRegistryRestInterceptor, "pre_create_rule" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = version.BatchDeleteVersionsRequest.pb( - version.BatchDeleteVersionsRequest() - ) + pb_message = gda_rule.CreateRuleRequest.pb(gda_rule.CreateRuleRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -25524,18 +35057,18 @@ def test_batch_delete_versions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(operations_pb2.Operation()) + return_value = gda_rule.Rule.to_json(gda_rule.Rule()) req.return_value.content = return_value - request = version.BatchDeleteVersionsRequest() + request = gda_rule.CreateRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() + post.return_value = gda_rule.Rule() - client.batch_delete_versions( + client.create_rule( request, metadata=[ ("key", "val"), @@ -25547,7 +35080,7 @@ def test_batch_delete_versions_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_files_rest_bad_request(request_type=file.ListFilesRequest): +def test_list_rules_rest_bad_request(request_type=rule.ListRulesRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -25566,17 +35099,17 @@ def test_list_files_rest_bad_request(request_type=file.ListFilesRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_files(request) + client.list_rules(request) @pytest.mark.parametrize( "request_type", [ - file.ListFilesRequest, + rule.ListRulesRequest, dict, ], ) -def test_list_files_rest_call_success(request_type): +def test_list_rules_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) @@ -25588,7 +35121,7 @@ def test_list_files_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = file.ListFilesResponse( + return_value = rule.ListRulesResponse( next_page_token="next_page_token_value", ) @@ -25597,19 +35130,19 @@ def test_list_files_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = file.ListFilesResponse.pb(return_value) + return_value = rule.ListRulesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_files(request) + response = client.list_rules(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFilesPager) + assert isinstance(response, pagers.ListRulesPager) assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_files_rest_interceptors(null_interceptor): +def test_list_rules_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25623,13 +35156,13 @@ def test_list_files_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_files" + transports.ArtifactRegistryRestInterceptor, "post_list_rules" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_files" + transports.ArtifactRegistryRestInterceptor, "pre_list_rules" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = file.ListFilesRequest.pb(file.ListFilesRequest()) + pb_message = rule.ListRulesRequest.pb(rule.ListRulesRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -25639,18 +35172,18 @@ def test_list_files_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = file.ListFilesResponse.to_json(file.ListFilesResponse()) + return_value = rule.ListRulesResponse.to_json(rule.ListRulesResponse()) req.return_value.content = return_value - request = file.ListFilesRequest() + request = rule.ListRulesRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = file.ListFilesResponse() + post.return_value = rule.ListRulesResponse() - client.list_files( + client.list_rules( request, metadata=[ ("key", "val"), @@ -25662,13 +35195,13 @@ def test_list_files_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_file_rest_bad_request(request_type=file.GetFileRequest): +def test_get_rule_rest_bad_request(request_type=rule.GetRuleRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" } request = request_type(**request_init) @@ -25683,34 +35216,35 @@ def test_get_file_rest_bad_request(request_type=file.GetFileRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_file(request) + client.get_rule(request) @pytest.mark.parametrize( "request_type", [ - file.GetFileRequest, + rule.GetRuleRequest, dict, ], ) -def test_get_file_rest_call_success(request_type): +def test_get_rule_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/files/sample4" + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = file.File( + return_value = rule.Rule( name="name_value", - size_bytes=1089, - owner="owner_value", + action=rule.Rule.Action.ALLOW, + operation=rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", ) # Wrap the value into a proper Response obj @@ -25718,21 +35252,22 @@ def test_get_file_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = file.File.pb(return_value) + return_value = rule.Rule.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_file(request) + response = client.get_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, file.File) + assert isinstance(response, rule.Rule) assert response.name == "name_value" - assert response.size_bytes == 1089 - assert response.owner == "owner_value" + assert response.action == rule.Rule.Action.ALLOW + assert response.operation == rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_file_rest_interceptors(null_interceptor): +def test_get_rule_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25746,13 +35281,13 @@ def test_get_file_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_file" + transports.ArtifactRegistryRestInterceptor, "post_get_rule" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_file" + transports.ArtifactRegistryRestInterceptor, "pre_get_rule" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = file.GetFileRequest.pb(file.GetFileRequest()) + pb_message = rule.GetRuleRequest.pb(rule.GetRuleRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -25762,18 +35297,18 @@ def test_get_file_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = file.File.to_json(file.File()) + return_value = rule.Rule.to_json(rule.Rule()) req.return_value.content = return_value - request = file.GetFileRequest() + request = rule.GetRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = file.File() + post.return_value = rule.Rule() - client.get_file( + client.get_rule( request, metadata=[ ("key", "val"), @@ -25785,13 +35320,15 @@ def test_get_file_rest_interceptors(null_interceptor): post.assert_called_once() -def test_list_tags_rest_bad_request(request_type=tag.ListTagsRequest): +def test_update_rule_rest_bad_request(request_type=gda_rule.UpdateRuleRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "rule": { + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" + } } request = request_type(**request_init) @@ -25806,32 +35343,116 @@ def test_list_tags_rest_bad_request(request_type=tag.ListTagsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.list_tags(request) + client.update_rule(request) @pytest.mark.parametrize( "request_type", [ - tag.ListTagsRequest, + gda_rule.UpdateRuleRequest, dict, ], ) -def test_list_tags_rest_call_success(request_type): +def test_update_rule_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "rule": { + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" + } + } + request_init["rule"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4", + "action": 1, + "operation": 1, + "condition": { + "expression": "expression_value", + "title": "title_value", + "description": "description_value", + "location": "location_value", + }, + "package_id": "package_id_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = gda_rule.UpdateRuleRequest.meta.fields["rule"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["rule"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["rule"][field])): + del request_init["rule"][field][i][subfield] + else: + del request_init["rule"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = tag.ListTagsResponse( - next_page_token="next_page_token_value", + return_value = gda_rule.Rule( + name="name_value", + action=gda_rule.Rule.Action.ALLOW, + operation=gda_rule.Rule.Operation.DOWNLOAD, + package_id="package_id_value", ) # Wrap the value into a proper Response obj @@ -25839,19 +35460,22 @@ def test_list_tags_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = tag.ListTagsResponse.pb(return_value) + return_value = gda_rule.Rule.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.list_tags(request) + response = client.update_rule(request) # 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_rule.Rule) + assert response.name == "name_value" + assert response.action == gda_rule.Rule.Action.ALLOW + assert response.operation == gda_rule.Rule.Operation.DOWNLOAD + assert response.package_id == "package_id_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_tags_rest_interceptors(null_interceptor): +def test_update_rule_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25865,13 +35489,13 @@ def test_list_tags_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_list_tags" + transports.ArtifactRegistryRestInterceptor, "post_update_rule" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_list_tags" + transports.ArtifactRegistryRestInterceptor, "pre_update_rule" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = tag.ListTagsRequest.pb(tag.ListTagsRequest()) + pb_message = gda_rule.UpdateRuleRequest.pb(gda_rule.UpdateRuleRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -25881,18 +35505,18 @@ def test_list_tags_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = tag.ListTagsResponse.to_json(tag.ListTagsResponse()) + return_value = gda_rule.Rule.to_json(gda_rule.Rule()) req.return_value.content = return_value - request = tag.ListTagsRequest() + request = gda_rule.UpdateRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = tag.ListTagsResponse() + post.return_value = gda_rule.Rule() - client.list_tags( + client.update_rule( request, metadata=[ ("key", "val"), @@ -25904,13 +35528,13 @@ def test_list_tags_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_tag_rest_bad_request(request_type=tag.GetTagRequest): +def test_delete_rule_rest_bad_request(request_type=rule.DeleteRuleRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" } request = request_type(**request_init) @@ -25925,54 +35549,46 @@ def test_get_tag_rest_bad_request(request_type=tag.GetTagRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_tag(request) + client.delete_rule(request) @pytest.mark.parametrize( "request_type", [ - tag.GetTagRequest, + rule.DeleteRuleRequest, dict, ], ) -def test_get_tag_rest_call_success(request_type): +def test_delete_rule_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + "name": "projects/sample1/locations/sample2/repositories/sample3/rules/sample4" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = tag.Tag( - name="name_value", - version="version_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = tag.Tag.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_tag(request) + response = client.delete_rule(request) # Establish that the response is the type that we expect. - assert isinstance(response, tag.Tag) - assert response.name == "name_value" - assert response.version == "version_value" + assert response is None @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_tag_rest_interceptors(null_interceptor): +def test_delete_rule_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -25986,13 +35602,10 @@ def test_get_tag_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_tag" - ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_tag" + transports.ArtifactRegistryRestInterceptor, "pre_delete_rule" ) as pre: pre.assert_not_called() - post.assert_not_called() - pb_message = tag.GetTagRequest.pb(tag.GetTagRequest()) + pb_message = rule.DeleteRuleRequest.pb(rule.DeleteRuleRequest()) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -26002,18 +35615,15 @@ def test_get_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = tag.Tag.to_json(tag.Tag()) - req.return_value.content = return_value - request = tag.GetTagRequest() + request = rule.DeleteRuleRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = tag.Tag() - client.get_tag( + client.delete_rule( request, metadata=[ ("key", "val"), @@ -26022,16 +35632,17 @@ def test_get_tag_rest_interceptors(null_interceptor): ) pre.assert_called_once() - post.assert_called_once() -def test_create_tag_rest_bad_request(request_type=gda_tag.CreateTagRequest): +def test_set_iam_policy_rest_bad_request( + request_type=iam_policy_pb2.SetIamPolicyRequest, +): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "resource": "projects/sample1/locations/sample2/repositories/sample3" } request = request_type(**request_init) @@ -26046,122 +35657,51 @@ def test_create_tag_rest_bad_request(request_type=gda_tag.CreateTagRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.create_tag(request) + client.set_iam_policy(request) @pytest.mark.parametrize( "request_type", [ - gda_tag.CreateTagRequest, + iam_policy_pb2.SetIamPolicyRequest, dict, ], ) -def test_create_tag_rest_call_success(request_type): +def test_set_iam_policy_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "parent": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + "resource": "projects/sample1/locations/sample2/repositories/sample3" } - request_init["tag"] = {"name": "name_value", "version": "version_value"} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_tag.CreateTagRequest.meta.fields["tag"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["tag"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["tag"][field])): - del request_init["tag"][field][i][subfield] - else: - del request_init["tag"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag( - name="name_value", - version="version_value", + return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.create_tag(request) + response = client.set_iam_policy(request) # 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.parametrize("null_interceptor", [True, False]) -def test_create_tag_rest_interceptors(null_interceptor): +def test_set_iam_policy_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26175,13 +35715,13 @@ def test_create_tag_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_create_tag" + transports.ArtifactRegistryRestInterceptor, "post_set_iam_policy" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_create_tag" + transports.ArtifactRegistryRestInterceptor, "pre_set_iam_policy" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = gda_tag.CreateTagRequest.pb(gda_tag.CreateTagRequest()) + pb_message = iam_policy_pb2.SetIamPolicyRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -26191,18 +35731,18 @@ def test_create_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = gda_tag.Tag.to_json(gda_tag.Tag()) + return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value - request = gda_tag.CreateTagRequest() + request = iam_policy_pb2.SetIamPolicyRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gda_tag.Tag() + post.return_value = policy_pb2.Policy() - client.create_tag( + client.set_iam_policy( request, metadata=[ ("key", "val"), @@ -26214,15 +35754,15 @@ def test_create_tag_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_tag_rest_bad_request(request_type=gda_tag.UpdateTagRequest): +def test_get_iam_policy_rest_bad_request( + request_type=iam_policy_pb2.GetIamPolicyRequest, +): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "tag": { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" - } + "resource": "projects/sample1/locations/sample2/repositories/sample3" } request = request_type(**request_init) @@ -26237,127 +35777,51 @@ def test_update_tag_rest_bad_request(request_type=gda_tag.UpdateTagRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_tag(request) + client.get_iam_policy(request) @pytest.mark.parametrize( "request_type", [ - gda_tag.UpdateTagRequest, + iam_policy_pb2.GetIamPolicyRequest, dict, ], ) -def test_update_tag_rest_call_success(request_type): +def test_get_iam_policy_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "tag": { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" - } - } - request_init["tag"] = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5", - "version": "version_value", + "resource": "projects/sample1/locations/sample2/repositories/sample3" } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = gda_tag.UpdateTagRequest.meta.fields["tag"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["tag"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["tag"][field])): - del request_init["tag"][field][i][subfield] - else: - del request_init["tag"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gda_tag.Tag( - name="name_value", - version="version_value", + return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_tag.Tag.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_tag(request) + response = client.get_iam_policy(request) # 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.parametrize("null_interceptor", [True, False]) -def test_update_tag_rest_interceptors(null_interceptor): +def test_get_iam_policy_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26371,13 +35835,13 @@ def test_update_tag_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_update_tag" + transports.ArtifactRegistryRestInterceptor, "post_get_iam_policy" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_update_tag" + transports.ArtifactRegistryRestInterceptor, "pre_get_iam_policy" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = gda_tag.UpdateTagRequest.pb(gda_tag.UpdateTagRequest()) + pb_message = iam_policy_pb2.GetIamPolicyRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -26387,18 +35851,18 @@ def test_update_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = gda_tag.Tag.to_json(gda_tag.Tag()) + return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value - request = gda_tag.UpdateTagRequest() + request = iam_policy_pb2.GetIamPolicyRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gda_tag.Tag() + post.return_value = policy_pb2.Policy() - client.update_tag( + client.get_iam_policy( request, metadata=[ ("key", "val"), @@ -26410,13 +35874,15 @@ def test_update_tag_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_tag_rest_bad_request(request_type=tag.DeleteTagRequest): +def test_test_iam_permissions_rest_bad_request( + request_type=iam_policy_pb2.TestIamPermissionsRequest, +): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + "resource": "projects/sample1/locations/sample2/repositories/sample3" } request = request_type(**request_init) @@ -26431,46 +35897,49 @@ def test_delete_tag_rest_bad_request(request_type=tag.DeleteTagRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.delete_tag(request) + client.test_iam_permissions(request) @pytest.mark.parametrize( "request_type", [ - tag.DeleteTagRequest, + iam_policy_pb2.TestIamPermissionsRequest, dict, ], ) -def test_delete_tag_rest_call_success(request_type): +def test_test_iam_permissions_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4/tags/sample5" + "resource": "projects/sample1/locations/sample2/repositories/sample3" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = None + return_value = iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - json_return_value = "" + json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.delete_tag(request) + response = client.test_iam_permissions(request) # Establish that the response is the type that we expect. - assert response is None + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert response.permissions == ["permissions_value"] @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_tag_rest_interceptors(null_interceptor): +def test_test_iam_permissions_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26484,10 +35953,13 @@ def test_delete_tag_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_delete_tag" + transports.ArtifactRegistryRestInterceptor, "post_test_iam_permissions" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_test_iam_permissions" ) as pre: pre.assert_not_called() - pb_message = tag.DeleteTagRequest.pb(tag.DeleteTagRequest()) + post.assert_not_called() + pb_message = iam_policy_pb2.TestIamPermissionsRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -26497,15 +35969,20 @@ def test_delete_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + return_value = json_format.MessageToJson( + iam_policy_pb2.TestIamPermissionsResponse() + ) + req.return_value.content = return_value - request = tag.DeleteTagRequest() + request = iam_policy_pb2.TestIamPermissionsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata + post.return_value = iam_policy_pb2.TestIamPermissionsResponse() - client.delete_tag( + client.test_iam_permissions( request, metadata=[ ("key", "val"), @@ -26514,18 +35991,17 @@ def test_delete_tag_rest_interceptors(null_interceptor): ) pre.assert_called_once() + post.assert_called_once() -def test_set_iam_policy_rest_bad_request( - request_type=iam_policy_pb2.SetIamPolicyRequest, +def test_get_project_settings_rest_bad_request( + request_type=settings.GetProjectSettingsRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } + request_init = {"name": "projects/sample1/projectSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26539,51 +36015,57 @@ def test_set_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.set_iam_policy(request) + client.get_project_settings(request) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.SetIamPolicyRequest, + settings.GetProjectSettingsRequest, dict, ], ) -def test_set_iam_policy_rest_call_success(request_type): +def test_get_project_settings_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } + request_init = {"name": "projects/sample1/projectSettings"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", + return_value = settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + pull_percent=1293, ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = settings.ProjectSettings.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.set_iam_policy(request) + response = client.get_project_settings(request) # 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 + ) + assert response.pull_percent == 1293 @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_iam_policy_rest_interceptors(null_interceptor): +def test_get_project_settings_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26597,13 +36079,15 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_set_iam_policy" + transports.ArtifactRegistryRestInterceptor, "post_get_project_settings" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_set_iam_policy" + transports.ArtifactRegistryRestInterceptor, "pre_get_project_settings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = iam_policy_pb2.SetIamPolicyRequest() + pb_message = settings.GetProjectSettingsRequest.pb( + settings.GetProjectSettingsRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -26613,18 +36097,18 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(policy_pb2.Policy()) + return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) req.return_value.content = return_value - request = iam_policy_pb2.SetIamPolicyRequest() + request = settings.GetProjectSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = policy_pb2.Policy() + post.return_value = settings.ProjectSettings() - client.set_iam_policy( + client.get_project_settings( request, metadata=[ ("key", "val"), @@ -26636,16 +36120,14 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_iam_policy_rest_bad_request( - request_type=iam_policy_pb2.GetIamPolicyRequest, +def test_update_project_settings_rest_bad_request( + request_type=settings.UpdateProjectSettingsRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } + request_init = {"project_settings": {"name": "projects/sample1/projectSettings"}} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26659,51 +36141,129 @@ def test_get_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_iam_policy(request) + client.update_project_settings(request) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.GetIamPolicyRequest, + settings.UpdateProjectSettingsRequest, dict, ], ) -def test_get_iam_policy_rest_call_success(request_type): +def test_update_project_settings_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" + request_init = {"project_settings": {"name": "projects/sample1/projectSettings"}} + request_init["project_settings"] = { + "name": "projects/sample1/projectSettings", + "legacy_redirection_state": 1, + "pull_percent": 1293, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = settings.UpdateProjectSettingsRequest.meta.fields["project_settings"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["project_settings"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["project_settings"][field])): + del request_init["project_settings"][field][i][subfield] + else: + del request_init["project_settings"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", + return_value = settings.ProjectSettings( + name="name_value", + legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + pull_percent=1293, ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = settings.ProjectSettings.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_iam_policy(request) + response = client.update_project_settings(request) # 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 + ) + assert response.pull_percent == 1293 @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_iam_policy_rest_interceptors(null_interceptor): +def test_update_project_settings_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26717,13 +36277,15 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_iam_policy" + transports.ArtifactRegistryRestInterceptor, "post_update_project_settings" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_iam_policy" + transports.ArtifactRegistryRestInterceptor, "pre_update_project_settings" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = iam_policy_pb2.GetIamPolicyRequest() + pb_message = settings.UpdateProjectSettingsRequest.pb( + settings.UpdateProjectSettingsRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -26733,18 +36295,18 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson(policy_pb2.Policy()) + return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) req.return_value.content = return_value - request = iam_policy_pb2.GetIamPolicyRequest() + request = settings.UpdateProjectSettingsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = policy_pb2.Policy() + post.return_value = settings.ProjectSettings() - client.get_iam_policy( + client.update_project_settings( request, metadata=[ ("key", "val"), @@ -26756,16 +36318,14 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): post.assert_called_once() -def test_test_iam_permissions_rest_bad_request( - request_type=iam_policy_pb2.TestIamPermissionsRequest, +def test_get_vpcsc_config_rest_bad_request( + request_type=vpcsc_config.GetVPCSCConfigRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } + request_init = {"name": "projects/sample1/locations/sample2/vpcscConfig"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26779,49 +36339,52 @@ def test_test_iam_permissions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.test_iam_permissions(request) + client.get_vpcsc_config(request) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.TestIamPermissionsRequest, + vpcsc_config.GetVPCSCConfigRequest, dict, ], ) -def test_test_iam_permissions_rest_call_success(request_type): +def test_get_vpcsc_config_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } + request_init = {"name": "projects/sample1/locations/sample2/vpcscConfig"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], + return_value = vpcsc_config.VPCSCConfig( + name="name_value", + vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = vpcsc_config.VPCSCConfig.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.test_iam_permissions(request) + response = client.get_vpcsc_config(request) # 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, vpcsc_config.VPCSCConfig) + assert response.name == "name_value" + assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_test_iam_permissions_rest_interceptors(null_interceptor): +def test_get_vpcsc_config_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26835,13 +36398,15 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_test_iam_permissions" + transports.ArtifactRegistryRestInterceptor, "post_get_vpcsc_config" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_test_iam_permissions" + transports.ArtifactRegistryRestInterceptor, "pre_get_vpcsc_config" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = iam_policy_pb2.TestIamPermissionsRequest() + pb_message = vpcsc_config.GetVPCSCConfigRequest.pb( + vpcsc_config.GetVPCSCConfigRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -26851,20 +36416,18 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = json_format.MessageToJson( - iam_policy_pb2.TestIamPermissionsResponse() - ) + return_value = vpcsc_config.VPCSCConfig.to_json(vpcsc_config.VPCSCConfig()) req.return_value.content = return_value - request = iam_policy_pb2.TestIamPermissionsRequest() + request = vpcsc_config.GetVPCSCConfigRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = iam_policy_pb2.TestIamPermissionsResponse() + post.return_value = vpcsc_config.VPCSCConfig() - client.test_iam_permissions( + client.get_vpcsc_config( request, metadata=[ ("key", "val"), @@ -26876,14 +36439,16 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_project_settings_rest_bad_request( - request_type=settings.GetProjectSettingsRequest, +def test_update_vpcsc_config_rest_bad_request( + request_type=gda_vpcsc_config.UpdateVPCSCConfigRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/projectSettings"} + request_init = { + "vpcsc_config": {"name": "projects/sample1/locations/sample2/vpcscConfig"} + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26897,31 +36462,104 @@ def test_get_project_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_project_settings(request) + client.update_vpcsc_config(request) @pytest.mark.parametrize( "request_type", [ - settings.GetProjectSettingsRequest, + gda_vpcsc_config.UpdateVPCSCConfigRequest, dict, ], ) -def test_get_project_settings_rest_call_success(request_type): +def test_update_vpcsc_config_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/projectSettings"} + request_init = { + "vpcsc_config": {"name": "projects/sample1/locations/sample2/vpcscConfig"} + } + request_init["vpcsc_config"] = { + "name": "projects/sample1/locations/sample2/vpcscConfig", + "vpcsc_policy": 1, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = gda_vpcsc_config.UpdateVPCSCConfigRequest.meta.fields["vpcsc_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["vpcsc_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vpcsc_config"][field])): + del request_init["vpcsc_config"][field][i][subfield] + else: + del request_init["vpcsc_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings( + 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, ) # Wrap the value into a proper Response obj @@ -26929,23 +36567,20 @@ def test_get_project_settings_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) + return_value = gda_vpcsc_config.VPCSCConfig.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_project_settings(request) + response = client.update_vpcsc_config(request) # 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.parametrize("null_interceptor", [True, False]) -def test_get_project_settings_rest_interceptors(null_interceptor): +def test_update_vpcsc_config_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -26959,14 +36594,14 @@ def test_get_project_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_project_settings" + transports.ArtifactRegistryRestInterceptor, "post_update_vpcsc_config" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_project_settings" + transports.ArtifactRegistryRestInterceptor, "pre_update_vpcsc_config" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = settings.GetProjectSettingsRequest.pb( - settings.GetProjectSettingsRequest() + pb_message = gda_vpcsc_config.UpdateVPCSCConfigRequest.pb( + gda_vpcsc_config.UpdateVPCSCConfigRequest() ) transcode.return_value = { "method": "post", @@ -26977,18 +36612,20 @@ def test_get_project_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) + return_value = gda_vpcsc_config.VPCSCConfig.to_json( + gda_vpcsc_config.VPCSCConfig() + ) req.return_value.content = return_value - request = settings.GetProjectSettingsRequest() + request = gda_vpcsc_config.UpdateVPCSCConfigRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = settings.ProjectSettings() + post.return_value = gda_vpcsc_config.VPCSCConfig() - client.get_project_settings( + client.update_vpcsc_config( request, metadata=[ ("key", "val"), @@ -27000,14 +36637,16 @@ def test_get_project_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_project_settings_rest_bad_request( - request_type=settings.UpdateProjectSettingsRequest, -): +def test_update_package_rest_bad_request(request_type=gda_package.UpdatePackageRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"project_settings": {"name": "projects/sample1/projectSettings"}} + request_init = { + "package": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -27021,33 +36660,40 @@ def test_update_project_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_project_settings(request) + client.update_package(request) @pytest.mark.parametrize( "request_type", [ - settings.UpdateProjectSettingsRequest, + gda_package.UpdatePackageRequest, dict, ], ) -def test_update_project_settings_rest_call_success(request_type): +def test_update_package_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"project_settings": {"name": "projects/sample1/projectSettings"}} - request_init["project_settings"] = { - "name": "projects/sample1/projectSettings", - "legacy_redirection_state": 1, + request_init = { + "package": { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4" + } + } + request_init["package"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/packages/sample4", + "display_name": "display_name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "annotations": {}, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = settings.UpdateProjectSettingsRequest.meta.fields["project_settings"] + test_field = gda_package.UpdatePackageRequest.meta.fields["package"] def get_message_fields(field): # Given a field which is a message (composite type), return a list with @@ -27075,7 +36721,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["project_settings"].items(): # pragma: NO COVER + for field, value in request_init["package"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -27105,18 +36751,18 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["project_settings"][field])): - del request_init["project_settings"][field][i][subfield] + for i in range(0, len(request_init["package"][field])): + del request_init["package"][field][i][subfield] else: - del request_init["project_settings"][field][subfield] + del request_init["package"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = settings.ProjectSettings( + return_value = gda_package.Package( name="name_value", - legacy_redirection_state=settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED, + display_name="display_name_value", ) # Wrap the value into a proper Response obj @@ -27124,23 +36770,20 @@ def get_message_fields(field): response_value.status_code = 200 # Convert return value to protobuf type - return_value = settings.ProjectSettings.pb(return_value) + return_value = gda_package.Package.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_project_settings(request) + response = client.update_package(request) # Establish that the response is the type that we expect. - assert isinstance(response, settings.ProjectSettings) + assert isinstance(response, gda_package.Package) assert response.name == "name_value" - assert ( - response.legacy_redirection_state - == settings.ProjectSettings.RedirectionState.REDIRECTION_FROM_GCR_IO_DISABLED - ) + assert response.display_name == "display_name_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_project_settings_rest_interceptors(null_interceptor): +def test_update_package_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27154,14 +36797,14 @@ def test_update_project_settings_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_update_project_settings" + transports.ArtifactRegistryRestInterceptor, "post_update_package" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_update_project_settings" + transports.ArtifactRegistryRestInterceptor, "pre_update_package" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = settings.UpdateProjectSettingsRequest.pb( - settings.UpdateProjectSettingsRequest() + pb_message = gda_package.UpdatePackageRequest.pb( + gda_package.UpdatePackageRequest() ) transcode.return_value = { "method": "post", @@ -27172,18 +36815,18 @@ def test_update_project_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) + return_value = gda_package.Package.to_json(gda_package.Package()) req.return_value.content = return_value - request = settings.UpdateProjectSettingsRequest() + request = gda_package.UpdatePackageRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = settings.ProjectSettings() + post.return_value = gda_package.Package() - client.update_project_settings( + client.update_package( request, metadata=[ ("key", "val"), @@ -27195,14 +36838,14 @@ def test_update_project_settings_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_vpcsc_config_rest_bad_request( - request_type=vpcsc_config.GetVPCSCConfigRequest, +def test_list_attachments_rest_bad_request( + request_type=attachment.ListAttachmentsRequest, ): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/vpcscConfig"} + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -27216,31 +36859,30 @@ def test_get_vpcsc_config_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.get_vpcsc_config(request) + client.list_attachments(request) @pytest.mark.parametrize( "request_type", [ - vpcsc_config.GetVPCSCConfigRequest, + attachment.ListAttachmentsRequest, dict, ], ) -def test_get_vpcsc_config_rest_call_success(request_type): +def test_list_attachments_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/vpcscConfig"} + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = vpcsc_config.VPCSCConfig( - name="name_value", - vpcsc_policy=vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, + return_value = attachment.ListAttachmentsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -27248,20 +36890,19 @@ def test_get_vpcsc_config_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = vpcsc_config.VPCSCConfig.pb(return_value) + return_value = attachment.ListAttachmentsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.get_vpcsc_config(request) + response = client.list_attachments(request) # Establish that the response is the type that we expect. - assert isinstance(response, vpcsc_config.VPCSCConfig) - assert response.name == "name_value" - assert response.vpcsc_policy == vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY + assert isinstance(response, pagers.ListAttachmentsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_vpcsc_config_rest_interceptors(null_interceptor): +def test_list_attachments_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27275,14 +36916,14 @@ def test_get_vpcsc_config_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_get_vpcsc_config" + transports.ArtifactRegistryRestInterceptor, "post_list_attachments" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_get_vpcsc_config" + transports.ArtifactRegistryRestInterceptor, "pre_list_attachments" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = vpcsc_config.GetVPCSCConfigRequest.pb( - vpcsc_config.GetVPCSCConfigRequest() + pb_message = attachment.ListAttachmentsRequest.pb( + attachment.ListAttachmentsRequest() ) transcode.return_value = { "method": "post", @@ -27293,18 +36934,20 @@ def test_get_vpcsc_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = vpcsc_config.VPCSCConfig.to_json(vpcsc_config.VPCSCConfig()) + return_value = attachment.ListAttachmentsResponse.to_json( + attachment.ListAttachmentsResponse() + ) req.return_value.content = return_value - request = vpcsc_config.GetVPCSCConfigRequest() + request = attachment.ListAttachmentsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = vpcsc_config.VPCSCConfig() + post.return_value = attachment.ListAttachmentsResponse() - client.get_vpcsc_config( + client.list_attachments( request, metadata=[ ("key", "val"), @@ -27316,15 +36959,13 @@ def test_get_vpcsc_config_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_vpcsc_config_rest_bad_request( - request_type=gda_vpcsc_config.UpdateVPCSCConfigRequest, -): +def test_get_attachment_rest_bad_request(request_type=attachment.GetAttachmentRequest): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "vpcsc_config": {"name": "projects/sample1/locations/sample2/vpcscConfig"} + "name": "projects/sample1/locations/sample2/repositories/sample3/attachments/sample4" } request = request_type(**request_init) @@ -27339,35 +36980,171 @@ def test_update_vpcsc_config_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value - client.update_vpcsc_config(request) + client.get_attachment(request) @pytest.mark.parametrize( "request_type", [ - gda_vpcsc_config.UpdateVPCSCConfigRequest, + attachment.GetAttachmentRequest, dict, ], ) -def test_update_vpcsc_config_rest_call_success(request_type): +def test_get_attachment_rest_call_success(request_type): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "vpcsc_config": {"name": "projects/sample1/locations/sample2/vpcscConfig"} + "name": "projects/sample1/locations/sample2/repositories/sample3/attachments/sample4" } - request_init["vpcsc_config"] = { - "name": "projects/sample1/locations/sample2/vpcscConfig", - "vpcsc_policy": 1, + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = attachment.Attachment( + name="name_value", + target="target_value", + type_="type__value", + attachment_namespace="attachment_namespace_value", + files=["files_value"], + oci_version_name="oci_version_name_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = attachment.Attachment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_attachment(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, attachment.Attachment) + assert response.name == "name_value" + assert response.target == "target_value" + assert response.type_ == "type__value" + assert response.attachment_namespace == "attachment_namespace_value" + assert response.files == ["files_value"] + assert response.oci_version_name == "oci_version_name_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_attachment_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_get_attachment" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_get_attachment" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = attachment.GetAttachmentRequest.pb( + attachment.GetAttachmentRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = attachment.Attachment.to_json(attachment.Attachment()) + req.return_value.content = return_value + + request = attachment.GetAttachmentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = attachment.Attachment() + + client.get_attachment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_attachment_rest_bad_request( + request_type=gda_attachment.CreateAttachmentRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.create_attachment(request) + + +@pytest.mark.parametrize( + "request_type", + [ + gda_attachment.CreateAttachmentRequest, + dict, + ], +) +def test_create_attachment_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init["attachment"] = { + "name": "name_value", + "target": "target_value", + "type_": "type__value", + "attachment_namespace": "attachment_namespace_value", + "annotations": {}, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "files": ["files_value1", "files_value2"], + "oci_version_name": "oci_version_name_value", } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = gda_vpcsc_config.UpdateVPCSCConfigRequest.meta.fields["vpcsc_config"] + test_field = gda_attachment.CreateAttachmentRequest.meta.fields["attachment"] def get_message_fields(field): # Given a field which is a message (composite type), return a list with @@ -27395,7 +37172,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["vpcsc_config"].items(): # pragma: NO COVER + for field, value in request_init["attachment"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -27425,39 +37202,31 @@ def get_message_fields(field): subfield = subfield_to_delete.get("subfield") if subfield: if field_repeated: - for i in range(0, len(request_init["vpcsc_config"][field])): - del request_init["vpcsc_config"][field][i][subfield] + for i in range(0, len(request_init["attachment"][field])): + del request_init["attachment"][field][i][subfield] else: - del request_init["vpcsc_config"][field][subfield] + del request_init["attachment"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = gda_vpcsc_config.VPCSCConfig( - name="name_value", - vpcsc_policy=gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY, - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = gda_vpcsc_config.VPCSCConfig.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value - response = client.update_vpcsc_config(request) + response = client.create_attachment(request) # Establish that the response is the type that we expect. - assert isinstance(response, gda_vpcsc_config.VPCSCConfig) - assert response.name == "name_value" - assert response.vpcsc_policy == gda_vpcsc_config.VPCSCConfig.VPCSCPolicy.DENY + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_vpcsc_config_rest_interceptors(null_interceptor): +def test_create_attachment_rest_interceptors(null_interceptor): transport = transports.ArtifactRegistryRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -27471,14 +37240,16 @@ def test_update_vpcsc_config_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "post_update_vpcsc_config" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_create_attachment" ) as post, mock.patch.object( - transports.ArtifactRegistryRestInterceptor, "pre_update_vpcsc_config" + transports.ArtifactRegistryRestInterceptor, "pre_create_attachment" ) as pre: pre.assert_not_called() post.assert_not_called() - pb_message = gda_vpcsc_config.UpdateVPCSCConfigRequest.pb( - gda_vpcsc_config.UpdateVPCSCConfigRequest() + pb_message = gda_attachment.CreateAttachmentRequest.pb( + gda_attachment.CreateAttachmentRequest() ) transcode.return_value = { "method": "post", @@ -27489,20 +37260,137 @@ def test_update_vpcsc_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = gda_vpcsc_config.VPCSCConfig.to_json( - gda_vpcsc_config.VPCSCConfig() + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = gda_attachment.CreateAttachmentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + + client.create_attachment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_delete_attachment_rest_bad_request( + request_type=attachment.DeleteAttachmentRequest, +): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/attachments/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + client.delete_attachment(request) + + +@pytest.mark.parametrize( + "request_type", + [ + attachment.DeleteAttachmentRequest, + dict, + ], +) +def test_delete_attachment_rest_call_success(request_type): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/attachments/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_attachment(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_attachment_rest_interceptors(null_interceptor): + transport = transports.ArtifactRegistryRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.ArtifactRegistryRestInterceptor(), + ) + client = ArtifactRegistryClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "post_delete_attachment" + ) as post, mock.patch.object( + transports.ArtifactRegistryRestInterceptor, "pre_delete_attachment" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = attachment.DeleteAttachmentRequest.pb( + attachment.DeleteAttachmentRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = gda_vpcsc_config.UpdateVPCSCConfigRequest() + request = attachment.DeleteAttachmentRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = gda_vpcsc_config.VPCSCConfig() + post.return_value = operations_pb2.Operation() - client.update_vpcsc_config( + client.delete_attachment( request, metadata=[ ("key", "val"), @@ -28163,6 +38051,26 @@ def test_batch_delete_versions_empty_call_rest(): assert args[0] == request_msg +# 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_update_version_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_version), "__call__") as call: + client.update_version(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_version.UpdateVersionRequest() + + assert args[0] == request_msg + + # 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_files_empty_call_rest(): @@ -28203,6 +38111,46 @@ def test_get_file_empty_call_rest(): assert args[0] == request_msg +# 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_delete_file_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_file), "__call__") as call: + client.delete_file(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = file.DeleteFileRequest() + + assert args[0] == request_msg + + +# 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_update_file_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_file), "__call__") as call: + client.update_file(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_file.UpdateFileRequest() + + assert args[0] == request_msg + + # 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_tags_empty_call_rest(): @@ -28303,6 +38251,106 @@ def test_delete_tag_empty_call_rest(): assert args[0] == request_msg +# 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_create_rule_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_rule), "__call__") as call: + client.create_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_rule.CreateRuleRequest() + + assert args[0] == request_msg + + +# 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_rules_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_rules), "__call__") as call: + client.list_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.ListRulesRequest() + + assert args[0] == request_msg + + +# 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_get_rule_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_rule), "__call__") as call: + client.get_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.GetRuleRequest() + + assert args[0] == request_msg + + +# 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_update_rule_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_rule), "__call__") as call: + client.update_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_rule.UpdateRuleRequest() + + assert args[0] == request_msg + + +# 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_delete_rule_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_rule), "__call__") as call: + client.delete_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = rule.DeleteRuleRequest() + + assert args[0] == request_msg + + # 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_set_iam_policy_empty_call_rest(): @@ -28451,6 +38499,110 @@ def test_update_vpcsc_config_empty_call_rest(): assert args[0] == request_msg +# 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_update_package_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_package), "__call__") as call: + client.update_package(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_package.UpdatePackageRequest() + + assert args[0] == request_msg + + +# 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_attachments_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_attachments), "__call__") as call: + client.list_attachments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.ListAttachmentsRequest() + + assert args[0] == request_msg + + +# 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_get_attachment_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_attachment), "__call__") as call: + client.get_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.GetAttachmentRequest() + + assert args[0] == request_msg + + +# 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_create_attachment_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_attachment), "__call__" + ) as call: + client.create_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = gda_attachment.CreateAttachmentRequest() + + assert args[0] == request_msg + + +# 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_delete_attachment_empty_call_rest(): + client = ArtifactRegistryClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_attachment), "__call__" + ) as call: + client.delete_attachment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = attachment.DeleteAttachmentRequest() + + assert args[0] == request_msg + + def test_artifact_registry_rest_lro_client(): client = ArtifactRegistryClient( credentials=ga_credentials.AnonymousCredentials(), @@ -28523,13 +38675,21 @@ def test_artifact_registry_base_transport(): "get_version", "delete_version", "batch_delete_versions", + "update_version", "list_files", "get_file", + "delete_file", + "update_file", "list_tags", "get_tag", "create_tag", "update_tag", "delete_tag", + "create_rule", + "list_rules", + "get_rule", + "update_rule", + "delete_rule", "set_iam_policy", "get_iam_policy", "test_iam_permissions", @@ -28537,6 +38697,11 @@ def test_artifact_registry_base_transport(): "update_project_settings", "get_vpcsc_config", "update_vpcsc_config", + "update_package", + "list_attachments", + "get_attachment", + "create_attachment", + "delete_attachment", "get_location", "list_locations", "get_operation", @@ -28881,12 +39046,21 @@ def test_artifact_registry_client_transport_session_collision(transport_name): session1 = client1.transport.batch_delete_versions._session session2 = client2.transport.batch_delete_versions._session assert session1 != session2 + session1 = client1.transport.update_version._session + session2 = client2.transport.update_version._session + assert session1 != session2 session1 = client1.transport.list_files._session session2 = client2.transport.list_files._session assert session1 != session2 session1 = client1.transport.get_file._session session2 = client2.transport.get_file._session assert session1 != session2 + session1 = client1.transport.delete_file._session + session2 = client2.transport.delete_file._session + assert session1 != session2 + session1 = client1.transport.update_file._session + session2 = client2.transport.update_file._session + assert session1 != session2 session1 = client1.transport.list_tags._session session2 = client2.transport.list_tags._session assert session1 != session2 @@ -28902,6 +39076,21 @@ def test_artifact_registry_client_transport_session_collision(transport_name): session1 = client1.transport.delete_tag._session session2 = client2.transport.delete_tag._session assert session1 != session2 + session1 = client1.transport.create_rule._session + session2 = client2.transport.create_rule._session + assert session1 != session2 + session1 = client1.transport.list_rules._session + session2 = client2.transport.list_rules._session + assert session1 != session2 + session1 = client1.transport.get_rule._session + session2 = client2.transport.get_rule._session + assert session1 != session2 + session1 = client1.transport.update_rule._session + session2 = client2.transport.update_rule._session + assert session1 != session2 + session1 = client1.transport.delete_rule._session + session2 = client2.transport.delete_rule._session + assert session1 != session2 session1 = client1.transport.set_iam_policy._session session2 = client2.transport.set_iam_policy._session assert session1 != session2 @@ -28923,6 +39112,21 @@ def test_artifact_registry_client_transport_session_collision(transport_name): session1 = client1.transport.update_vpcsc_config._session session2 = client2.transport.update_vpcsc_config._session assert session1 != session2 + session1 = client1.transport.update_package._session + session2 = client2.transport.update_package._session + assert session1 != session2 + session1 = client1.transport.list_attachments._session + session2 = client2.transport.list_attachments._session + assert session1 != session2 + session1 = client1.transport.get_attachment._session + session2 = client2.transport.get_attachment._session + assert session1 != session2 + session1 = client1.transport.create_attachment._session + session2 = client2.transport.create_attachment._session + assert session1 != session2 + session1 = client1.transport.delete_attachment._session + session2 = client2.transport.delete_attachment._session + assert session1 != session2 def test_artifact_registry_grpc_transport_channel(): @@ -29116,11 +39320,42 @@ def test_parse_apt_artifact_path(): assert expected == actual -def test_docker_image_path(): +def test_attachment_path(): project = "winkle" location = "nautilus" repository = "scallop" - docker_image = "abalone" + attachment = "abalone" + expected = "projects/{project}/locations/{location}/repositories/{repository}/attachments/{attachment}".format( + project=project, + location=location, + repository=repository, + attachment=attachment, + ) + actual = ArtifactRegistryClient.attachment_path( + project, location, repository, attachment + ) + assert expected == actual + + +def test_parse_attachment_path(): + expected = { + "project": "squid", + "location": "clam", + "repository": "whelk", + "attachment": "octopus", + } + path = ArtifactRegistryClient.attachment_path(**expected) + + # Check that the path construction is reversible. + actual = ArtifactRegistryClient.parse_attachment_path(path) + assert expected == actual + + +def test_docker_image_path(): + project = "oyster" + location = "nudibranch" + repository = "cuttlefish" + docker_image = "mussel" expected = "projects/{project}/locations/{location}/repositories/{repository}/dockerImages/{docker_image}".format( project=project, location=location, @@ -29135,10 +39370,10 @@ def test_docker_image_path(): def test_parse_docker_image_path(): expected = { - "project": "squid", - "location": "clam", - "repository": "whelk", - "docker_image": "octopus", + "project": "winkle", + "location": "nautilus", + "repository": "scallop", + "docker_image": "abalone", } path = ArtifactRegistryClient.docker_image_path(**expected) @@ -29148,10 +39383,10 @@ def test_parse_docker_image_path(): def test_file_path(): - project = "oyster" - location = "nudibranch" - repository = "cuttlefish" - file = "mussel" + project = "squid" + location = "clam" + repository = "whelk" + file = "octopus" expected = "projects/{project}/locations/{location}/repositories/{repository}/files/{file}".format( project=project, location=location, @@ -29164,10 +39399,10 @@ def test_file_path(): def test_parse_file_path(): expected = { - "project": "winkle", - "location": "nautilus", - "repository": "scallop", - "file": "abalone", + "project": "oyster", + "location": "nudibranch", + "repository": "cuttlefish", + "file": "mussel", } path = ArtifactRegistryClient.file_path(**expected) @@ -29177,10 +39412,10 @@ def test_parse_file_path(): def test_maven_artifact_path(): - project = "squid" - location = "clam" - repository = "whelk" - maven_artifact = "octopus" + project = "winkle" + location = "nautilus" + repository = "scallop" + maven_artifact = "abalone" expected = "projects/{project}/locations/{location}/repositories/{repository}/mavenArtifacts/{maven_artifact}".format( project=project, location=location, @@ -29195,10 +39430,10 @@ def test_maven_artifact_path(): def test_parse_maven_artifact_path(): expected = { - "project": "oyster", - "location": "nudibranch", - "repository": "cuttlefish", - "maven_artifact": "mussel", + "project": "squid", + "location": "clam", + "repository": "whelk", + "maven_artifact": "octopus", } path = ArtifactRegistryClient.maven_artifact_path(**expected) @@ -29208,10 +39443,10 @@ def test_parse_maven_artifact_path(): def test_npm_package_path(): - project = "winkle" - location = "nautilus" - repository = "scallop" - npm_package = "abalone" + project = "oyster" + location = "nudibranch" + repository = "cuttlefish" + npm_package = "mussel" expected = "projects/{project}/locations/{location}/repositories/{repository}/npmPackages/{npm_package}".format( project=project, location=location, @@ -29226,10 +39461,10 @@ def test_npm_package_path(): def test_parse_npm_package_path(): expected = { - "project": "squid", - "location": "clam", - "repository": "whelk", - "npm_package": "octopus", + "project": "winkle", + "location": "nautilus", + "repository": "scallop", + "npm_package": "abalone", } path = ArtifactRegistryClient.npm_package_path(**expected) @@ -29239,10 +39474,10 @@ def test_parse_npm_package_path(): def test_package_path(): - project = "oyster" - location = "nudibranch" - repository = "cuttlefish" - package = "mussel" + project = "squid" + location = "clam" + repository = "whelk" + package = "octopus" expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}".format( project=project, location=location, @@ -29255,10 +39490,10 @@ def test_package_path(): def test_parse_package_path(): expected = { - "project": "winkle", - "location": "nautilus", - "repository": "scallop", - "package": "abalone", + "project": "oyster", + "location": "nudibranch", + "repository": "cuttlefish", + "package": "mussel", } path = ArtifactRegistryClient.package_path(**expected) @@ -29268,7 +39503,7 @@ def test_parse_package_path(): def test_project_settings_path(): - project = "squid" + project = "winkle" expected = "projects/{project}/projectSettings".format( project=project, ) @@ -29278,7 +39513,7 @@ def test_project_settings_path(): def test_parse_project_settings_path(): expected = { - "project": "clam", + "project": "nautilus", } path = ArtifactRegistryClient.project_settings_path(**expected) @@ -29288,10 +39523,10 @@ def test_parse_project_settings_path(): def test_python_package_path(): - project = "whelk" - location = "octopus" - repository = "oyster" - python_package = "nudibranch" + project = "scallop" + location = "abalone" + repository = "squid" + python_package = "clam" expected = "projects/{project}/locations/{location}/repositories/{repository}/pythonPackages/{python_package}".format( project=project, location=location, @@ -29306,10 +39541,10 @@ def test_python_package_path(): def test_parse_python_package_path(): expected = { - "project": "cuttlefish", - "location": "mussel", - "repository": "winkle", - "python_package": "nautilus", + "project": "whelk", + "location": "octopus", + "repository": "oyster", + "python_package": "nudibranch", } path = ArtifactRegistryClient.python_package_path(**expected) @@ -29319,9 +39554,9 @@ def test_parse_python_package_path(): def test_repository_path(): - project = "scallop" - location = "abalone" - repository = "squid" + project = "cuttlefish" + location = "mussel" + repository = "winkle" expected = ( "projects/{project}/locations/{location}/repositories/{repository}".format( project=project, @@ -29335,9 +39570,9 @@ def test_repository_path(): def test_parse_repository_path(): expected = { - "project": "clam", - "location": "whelk", - "repository": "octopus", + "project": "nautilus", + "location": "scallop", + "repository": "abalone", } path = ArtifactRegistryClient.repository_path(**expected) @@ -29346,10 +39581,39 @@ def test_parse_repository_path(): assert expected == actual +def test_rule_path(): + project = "squid" + location = "clam" + repository = "whelk" + rule = "octopus" + expected = "projects/{project}/locations/{location}/repositories/{repository}/rules/{rule}".format( + project=project, + location=location, + repository=repository, + rule=rule, + ) + actual = ArtifactRegistryClient.rule_path(project, location, repository, rule) + assert expected == actual + + +def test_parse_rule_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "repository": "cuttlefish", + "rule": "mussel", + } + path = ArtifactRegistryClient.rule_path(**expected) + + # Check that the path construction is reversible. + actual = ArtifactRegistryClient.parse_rule_path(path) + assert expected == actual + + def test_secret_version_path(): - project = "oyster" - secret = "nudibranch" - secret_version = "cuttlefish" + project = "winkle" + secret = "nautilus" + secret_version = "scallop" expected = "projects/{project}/secrets/{secret}/versions/{secret_version}".format( project=project, secret=secret, @@ -29361,9 +39625,9 @@ def test_secret_version_path(): def test_parse_secret_version_path(): expected = { - "project": "mussel", - "secret": "winkle", - "secret_version": "nautilus", + "project": "abalone", + "secret": "squid", + "secret_version": "clam", } path = ArtifactRegistryClient.secret_version_path(**expected) @@ -29373,11 +39637,11 @@ def test_parse_secret_version_path(): def test_tag_path(): - project = "scallop" - location = "abalone" - repository = "squid" - package = "clam" - tag = "whelk" + project = "whelk" + location = "octopus" + repository = "oyster" + package = "nudibranch" + tag = "cuttlefish" expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag}".format( project=project, location=location, @@ -29393,11 +39657,11 @@ def test_tag_path(): def test_parse_tag_path(): expected = { - "project": "octopus", - "location": "oyster", - "repository": "nudibranch", - "package": "cuttlefish", - "tag": "mussel", + "project": "mussel", + "location": "winkle", + "repository": "nautilus", + "package": "scallop", + "tag": "abalone", } path = ArtifactRegistryClient.tag_path(**expected) @@ -29407,11 +39671,11 @@ def test_parse_tag_path(): def test_version_path(): - project = "winkle" - location = "nautilus" - repository = "scallop" - package = "abalone" - version = "squid" + project = "squid" + location = "clam" + repository = "whelk" + package = "octopus" + version = "oyster" expected = "projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/versions/{version}".format( project=project, location=location, @@ -29427,11 +39691,11 @@ def test_version_path(): def test_parse_version_path(): expected = { - "project": "clam", - "location": "whelk", - "repository": "octopus", - "package": "oyster", - "version": "nudibranch", + "project": "nudibranch", + "location": "cuttlefish", + "repository": "mussel", + "package": "winkle", + "version": "nautilus", } path = ArtifactRegistryClient.version_path(**expected) @@ -29441,8 +39705,8 @@ def test_parse_version_path(): def test_vpcsc_config_path(): - project = "cuttlefish" - location = "mussel" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}/vpcscConfig".format( project=project, location=location, @@ -29453,8 +39717,8 @@ def test_vpcsc_config_path(): def test_parse_vpcsc_config_path(): expected = { - "project": "winkle", - "location": "nautilus", + "project": "squid", + "location": "clam", } path = ArtifactRegistryClient.vpcsc_config_path(**expected) @@ -29464,10 +39728,10 @@ def test_parse_vpcsc_config_path(): def test_yum_artifact_path(): - project = "scallop" - location = "abalone" - repository = "squid" - yum_artifact = "clam" + project = "whelk" + location = "octopus" + repository = "oyster" + yum_artifact = "nudibranch" expected = "projects/{project}/locations/{location}/repositories/{repository}/yumArtifacts/{yum_artifact}".format( project=project, location=location, @@ -29482,10 +39746,10 @@ def test_yum_artifact_path(): def test_parse_yum_artifact_path(): expected = { - "project": "whelk", - "location": "octopus", - "repository": "oyster", - "yum_artifact": "nudibranch", + "project": "cuttlefish", + "location": "mussel", + "repository": "winkle", + "yum_artifact": "nautilus", } path = ArtifactRegistryClient.yum_artifact_path(**expected) @@ -29495,7 +39759,7 @@ def test_parse_yum_artifact_path(): def test_common_billing_account_path(): - billing_account = "cuttlefish" + billing_account = "scallop" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -29505,7 +39769,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "mussel", + "billing_account": "abalone", } path = ArtifactRegistryClient.common_billing_account_path(**expected) @@ -29515,7 +39779,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "winkle" + folder = "squid" expected = "folders/{folder}".format( folder=folder, ) @@ -29525,7 +39789,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nautilus", + "folder": "clam", } path = ArtifactRegistryClient.common_folder_path(**expected) @@ -29535,7 +39799,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "scallop" + organization = "whelk" expected = "organizations/{organization}".format( organization=organization, ) @@ -29545,7 +39809,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "abalone", + "organization": "octopus", } path = ArtifactRegistryClient.common_organization_path(**expected) @@ -29555,7 +39819,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "squid" + project = "oyster" expected = "projects/{project}".format( project=project, ) @@ -29565,7 +39829,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "clam", + "project": "nudibranch", } path = ArtifactRegistryClient.common_project_path(**expected) @@ -29575,8 +39839,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "whelk" - location = "octopus" + project = "cuttlefish" + location = "mussel" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -29587,8 +39851,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "oyster", - "location": "nudibranch", + "project": "winkle", + "location": "nautilus", } path = ArtifactRegistryClient.common_location_path(**expected)